from datetime import datetime

from pydriller import RepositoryMining
import json



projects_list = [
'https://github.com/karma-runner/karma',
'https://github.com/pester/Pester',
'https://github.com/cucumber/aruba',
'https://github.com/codegram/spinach',
'https://github.com/DATA-DOG/godog',
'https://github.com/continuumsecurity/bdd-security',
'https://github.com/acuminous/yadda',
'https://github.com/rlisagor/freshen',
'https://github.com/pyistanbul/dbpatterns',
'https://github.com/mucsi96/nightwatch-cucumber',
'https://github.com/jan-molak/serenity-js',
'https://github.com/django-behave/django-behave',
'https://github.com/strongqa/howitzer',
'https://github.com/meadsteve/white-bread',
'https://github.com/gucumber/gucumber',
'https://github.com/salad/salad',
'https://github.com/apiaryio/gavel-spec',
'https://github.com/cpp-testing/GUnit',
'https://github.com/calabash/x-platform-example',
'https://github.com/paulgibbs/behat-wordpress-extension',
'https://github.com/imkira/cukunity',
'https://github.com/behave/behave-django',
'https://github.com/BitBagCommerce/SyliusCmsPlugin',
'https://github.com/john-doherty/selenium-cucumber-js',
'https://github.com/gauravkarvir/cucumber_testng_java',
'https://github.com/qmetry/qaf',
'https://github.com/serenity-bdd/serenity-cucumber',
'https://github.com/machzqcq/CucumberJVMExamples',
'https://github.com/selenium-cucumber/selenium-cucumber-java',
'https://github.com/davidmfoley/storevil',
'https://github.com/Halleck45/BDDWizard',
'https://github.com/cabbage-ex/cabbage',
'https://github.com/amiya-pattnaik/webdriverIO-with-cucumberBDD',
'https://github.com/mklabs/mocha-gherkin',
'https://github.com/everzet/fullstack-bdd-sflive2012',
'https://github.com/gphilipp/bdd-guide-clojure',
'https://github.com/aloetesting/aloe',
'https://github.com/Shashikant86/bddfire',
'https://github.com/pjlsergeant/test-bdd-cucumber-perl',
'https://github.com/noblesamurai/cucumis',
'https://github.com/bbc/ShouldIT',
'https://github.com/hidroh/cucumber-api',
'https://github.com/ekino/veggies',
'https://github.com/tobiasheine/Movies',
'https://github.com/lewismj/cucumber',
'https://github.com/matt-allan/quicksilver',
'https://github.com/Chorus-bdd/Chorus',
'https://github.com/fesor/json_spec',
'https://github.com/mikek/behave-http',
'https://github.com/angiejones/restassured-with-cucumber-demo',
'https://github.com/dcypherthis/wdio-boilerplate-cucumber',
'https://github.com/ustwo/bdd-crossplatform-apps',
'https://github.com/flashquartermaster/Cuke4AS3',
'https://github.com/priyankshah217/AppiumCucumberTest',
'https://github.com/serenity-bdd/serenity-documentation',
'https://github.com/yoshuawuyts/cuke-tap',
'https://github.com/gorghoa/ScenarioStateBehatExtension',
'https://github.com/PredixDev/predix-bdd-cucumber',
'https://github.com/ttutisani/Xunit.Gherkin.Quick',
'https://github.com/Shashikant86/cucumber-appium',
#'https://github.com/Soluto/containers-security-project',  SÓ POSSUI FEATURES, NÃO POSSUI CÓDIGO
'https://github.com/graze/cucumber-rest-bdd',
'https://github.com/CodemateLtd/Android-Cucumber-BDD-Sample',
'https://github.com/bmsantos/cola-tests',
'https://github.com/ismaild/flaskr-bdd',
'https://github.com/tychobrailleur/cucumber-jvm-examples',
'https://github.com/bbqsrc/cucumber-rust',
'https://github.com/ravolt/BravoDelta',
'https://github.com/authomatic/liveandletdie',
'https://github.com/pib/calabash',
'https://github.com/Fidano/ColdCukes',
'https://github.com/sorin-costea/bdd',
'https://github.com/stanfy/behave-rest',
'https://github.com/mvallebr/BDD-java-cucumber-selenium',
'https://github.com/gabrielfalcao/tornado-bdd-sample',
'https://github.com/aloetesting/aloe_django',
'https://github.com/angiejones/automation-framework',
'https://github.com/Galad/tranquire',
'https://github.com/DavidSouther/tdd-angular',
'https://github.com/rpfujiw/gui-auto-uat',
'https://github.com/RobGibbens/BddWithXamarinUITest',
'https://github.com/serenity-bdd/serenity-cucumber-starter',
'https://github.com/andrewjc/kheera-testrunner-android',
'https://github.com/speciphy/speciphy',
'https://github.com/havvg/BDD-Experiment',
'https://github.com/serhatbolsu/appium-python-bdd',
'https://github.com/eugene-sea/karma-cucumber-js',
'https://github.com/larryg01/klassi-js',
'https://github.com/coshx/docker-bdd',
'https://github.com/balamaci/blog-ui-bdd-testing',
'https://github.com/oleg-toporkov/python-bdd-selenium',
'https://github.com/selenium-cucumber/selenium-cucumber-java-maven-example',
'https://github.com/porscheinformatik/cucumber-report-db',
'https://github.com/giggio-samples/Exemplo-BDD-com-CSharp-Specflow-e-Headless-Browser',
'https://github.com/thiagodp/concordialang',
'https://github.com/serenity-bdd/the-serenity-book',
'https://github.com/ahus1/bdd-examples',
'https://github.com/Remchi/libapp',
'https://github.com/mikehale/chef-bdd',
'https://github.com/jharmn/TwitterRestTests',
'https://github.com/sizuhiko/cakephp3-bdd-example',
'https://github.com/sbtqa/api-factory',
'https://github.com/johnnonolan/ChessBoard-Kata',
'https://github.com/rahulrathore44/SeleniumCucumber',
'https://github.com/20tab/django-bdd-toolkit',
'https://github.com/harlanji/gogherkit',
'https://github.com/tinyerp/openobject-mirliton',
'https://github.com/marcusoftnet/BDDWithSpecFlow',
'https://github.com/d-led/cpp-testing-no-excuses',
'https://github.com/hdorgeval/cucumber-ts-starter',
'https://github.com/olegpidsadnyi/pytest-bdd-example',
'https://github.com/pradeepta02/python-behave-automation-framework',
'https://github.com/shankybnl/selenium_BDD_framework',
'https://github.com/jamesotron/Baseline',
'https://github.com/petersuhm/laravel-bdd',
'https://github.com/joshski/cucumbers-on-vine-hill',
'https://github.com/chwilliamson/Vizregress',
'https://github.com/serenity-bdd/bdd-trader',
'https://github.com/ashenwgt/awesome-bdd-with-cucumber',
'https://github.com/AndyLPK247/behavior-driven-python',
'https://github.com/testdrivenio/django-aloe-bdd',
'https://github.com/jharmn/api-bdd-tests',
'https://github.com/readyapi/testserver-cucumber',
'https://github.com/sauliuz/nightmare-cucumberjs',
'https://github.com/mattwynne/bdd-as-if-you-meant-it',
'https://github.com/bmsantos/cola-maven-plugin',
'https://github.com/cliftonc/drupal_behat',
'https://github.com/colinbut/sales-order-system',
'https://github.com/IgorJorobus/cocot',
'https://github.com/malavbhavsar/BestBay',
'https://github.com/louisandkatherine/ti-uiautomator',
'https://github.com/dajudge/testee.fi',
'https://github.com/fsouza/lettuce_hudson_fabric',
'https://github.com/daniel-hall/TestKit',
'https://github.com/saasbook/hw-bdd-cucumber',
'https://github.com/katalon-studio-samples/katalon-bdd-cucumber-tests',
'https://github.com/spilio/apispots-bdd',
'https://github.com/ing-bank/bdd-mobile-security-automation-framework',
'https://github.com/Qualitestuk/SerenityBDD-Appium-Cross-Platform-Testing-Solution',
'https://github.com/skalnik/TDD-BDD-Example',
'https://github.com/rafaelcruz-net/BDD',
'https://github.com/giggio-samples/Exemplo-Blog-BDD-CSharp',
'https://github.com/yuowo/learning',
'https://github.com/mookid8000/DillPickle',
'https://github.com/fdiasdev/bdd-behat',
'https://github.com/hammernight/etsy_cucumber_taza_tutorial',
'https://github.com/jagilpe/bdd-pact-microservices',
'https://github.com/mattwynne/bdd-exchange-london-2011-code',
'https://github.com/erikedin/ExecutableSpecifications.jl',
'https://github.com/giggio-samples/outro-exemplo-de-bdd-com-csharp',
'https://github.com/shaunc/cucumber_nim',
'https://github.com/Chorus-bdd/chorus-js',
'https://github.com/spyoungtech/behave-webdriver',
'https://github.com/kkrac/ProSpec',
'https://github.com/Frameworkium/frameworkium-bdd',
'https://github.com/blu-corner/etiqet',
'https://github.com/Rhoynar/python-selenium-bdd',
'https://github.com/chibisov/cli-bdd',
'https://github.com/mhurwi/cucumber-meteor-tutorial',
'https://github.com/alexgarzao/victory.backup',
'https://github.com/meza/AAO',
'https://github.com/serenity-js/tutorial-from-scripts-to-serenity',
'https://github.com/sukesh15/BDDWorkshop',
'https://github.com/phodal/bdd-frameworks-compare',
'https://github.com/dunossauro/python-bdd-compare',
'https://github.com/vlasar/bdd_on_rails4_2',
'https://github.com/cedaniel200/base_project_for_web_automation_projects',
'https://github.com/navalkgupta/protractor-cucumber-tests',
'https://github.com/anair-it/drools-cucumber',
'https://github.com/llonchj/browsersteps',
'https://github.com/hugobarauna/forca',
'https://github.com/martinschneider/justtestlah',
'https://github.com/Xceptance/neodymium-library',
'https://github.com/lucascourot/PHPKataTrainReservation',
'https://github.com/wesovilabs/gherkinize',
'https://github.com/dariusz-wozniak/TddBook-Code',
'https://github.com/shane51/BDD_PageObject_Appium_automation',
'https://github.com/serenity-bdd/serenity-exercises',
'https://github.com/sabre1041/ose-bdd-demo',
'https://github.com/jholsgrove/BDDRestSharp',
'https://github.com/DanteLore/bdd-spark',
'https://github.com/mica16/BDD-TDD-Demo',
'https://github.com/devpaul/node-bdd-example',
'https://github.com/jenkins-x/godog-jx',
'https://github.com/MarkBorcherding/AgentBdd',
'https://github.com/raghuk9/PhotonLabs_AutomationFramework_BDD_TDMS_MDD',
'https://github.com/the-creative-tester/python-behave-web-browser-automation-example',
'https://github.com/joshuaswarren/bdd',
'https://github.com/behave-restful/behave-restful',
'https://github.com/blaix/bddgen',
'https://github.com/serenity-js/seed-cucumber',
'https://github.com/kinisoftware/BDD-Java',
# 'https://github.com/grantjforrester/bdd-rest', FOI DELETADO! NÃO EXISTE MAIS!
'https://github.com/BitBagCommerce/SyliusBDD',
'https://github.com/jbandi/bowling-bdd-java',
'https://github.com/exu/php-bdd-bootstrap',
'https://github.com/dwilkie/rails_bdd_course',
'https://github.com/waheedahmed55/Hybrid-Selenium-Cucumber-BDD',
'https://github.com/matason/behat-drupal',
'https://github.com/inv/t4',
'https://github.com/Nethereum/Nethereum.TestRPCRunner',
'https://github.com/AlexandrosD/ng2-protractor-cucumber',
'https://github.com/froots/snippetron',
'https://github.com/joymax/lettuce-web',
'https://github.com/haschi/dominium',
'https://github.com/katalisha/behat-tutorial',
'https://github.com/davidemoro/cookiecutter-qa',
'https://github.com/ericyahhh/spectron-cucumber-example',
'https://github.com/symonk/cucumber-jvm-selenium-allure2-test-automation-framework',
'https://github.com/harry-kalligeros/serenityjs-demo',
'https://github.com/ukrvassabi/serenity-bdd-test',
'https://github.com/julialiuliu/Appium-BDD-python-mobile-app-testing',
'https://github.com/serenity-bdd/serenity-cli',
'https://github.com/Substeps/substeps-framework',
# 'https://github.com/theodesp/bdd-javascript', SÓ TEM FEATURES, NÃO TEM CÓDIGO
'https://github.com/js-republic/cucumber-slice-by-slice-workshop',
'https://github.com/stmllr/TYPO3-BDD',
'https://github.com/Mah-D/DwarfCucumber',
'https://github.com/haroon-sheikh/cucumber-appium-ruby-example',
'https://github.com/serenity-dojo/caffeinate-me',
'https://github.com/marcusoftnet/BDDAsYouMeanIt',
'https://github.com/sizuhiko/BddExampleApp',
'https://github.com/sitture/cucumber-jvm-extentreport',
'https://github.com/William-Yeh/docker-behave',
'https://github.com/yurireeis/bddocs'
]


# text_file = open("repos.txt", "r")
# lines = text_file.readlines()

# dt1 = datetime(2016, 10, 8, 17, 0, 0)
# dt2 = datetime.now()

for line in projects_list:

    print('Verificando repositório!')

    try:
        result = open('result.json')
        config = json.load(result)
    except IOError:
        print('Arquivo inexistente')
        config = []

    if any(d['project'] == line for d in config):
        print('Repositório já analisado!')
    else:
        print('Buscando repositório: ', line)

        commits_bdd = RepositoryMining(line,
                                       only_modifications_with_file_types=['.feature'],
                                       reversed_order=True).traverse_commits()

        commits_code = RepositoryMining(line, only_modifications_with_file_types=['.rb', '.js', '.html',
                                                                                  '.c', '.cpp', '.py',
                                                                                  '.java', '.net', 'ps1',
                                                                                  'ps1xml', '.go', '.exs',
                                                                                  '.sh', '.php', '.clj',
                                                                                  '.pl', '.scala', '.sbt',
                                                                                  '.properties', '.xml',
                                                                                  '.cs', '.csproj', '.rs', '.erl',
                                                                                  '.data', '.config', '.rockspec',
                                                                                  '.lua', '.cfc', '.cfm', '.ts',
                                                                                  '.css', '.apk', '.swift', '.jl',
                                                                                  '.nim', '.nimble'],
                                        reversed_order=True).traverse_commits()

        bdd = '{}'.format(next(commits_bdd).committer_date.date())
        code = '{}'.format(next(commits_code).committer_date.date())

        data = {"project": line, "bdd": bdd, "code": code}

        config.append(data)

        with open('result.json', 'w') as f:
            json.dump(config, f)

    print('--------------------------------------------------------')
