def update_all(logger, days): """ Run the script for all currently tracked repositories. :param logger: LOGGER object :param days: Number of days (int) for which FIC will generate the changelog.md data tables. """ config = "." commit_message = "Changelog: " + str(datetime.utcnow()) files = ["git_files", "hg_files", "changelog.json", "changelog.md"] update_fic_files = Github(files, commit_message, LOGGER, config) update_fic_files.git_pull() logger.info("======== Logging in ALL mode on %s ========", datetime.now()) git_data = create_files_for_git(REPOSITORIES, onerepo=False) hg_data = create_files_for_hg(REPOSITORIES, onerepo=False) # Take git and hg data, write it to changelog.json changelog_data = {} changelog_data.update({"Github": git_data}) changelog_data.update({"Hg": hg_data}) data_file = open("changelog.json", "w") json.dump(changelog_data, data_file, indent=2) data_file.close() clear_file("changelog.md", int(days)) generate_main_md_table(REPOSITORIES, "complete", int(days)) update_fic_files.git_add() update_fic_files.git_commit() update_fic_files.git_push()
def run_hg(logger, days): """ Run the script only for HG repositories that are currently tracked. :param logger: LOGGER object :param days: Number of days (int) for which FIC will generate the changelog.md data tables. """ logger.info("======== Logging in HG mode on %s ========", datetime.now()) hg_data = create_files_for_hg(REPOSITORIES, onerepo=False) repo_name = "Hg" write_to_changelog_json(hg_data, repo_name) clear_file("changelog.md", int(days)) generate_main_md_table(REPOSITORIES, "Hg", int(days)) click.echo("Script ran in HG Only mode")
def run_all(logger, days): """ Run the script for all currently tracked repositories. :param logger: LOGGER object :param days: Number of days (int) for which FIC will generate the changelog.md data tables. """ logger.info("======== Logging in ALL mode on %s ========", datetime.now()) git_data = create_files_for_git(REPOSITORIES, onerepo=False) hg_data = create_files_for_hg(REPOSITORIES, onerepo=False) # Take git and hg data, write it to changelog.json changelog_data = {} changelog_data.update({"Github": git_data}) changelog_data.update({"Hg": hg_data}) data_file = open("changelog.json", "w") json.dump(changelog_data, data_file, indent=2) data_file.close() clear_file("changelog.md", int(days)) generate_main_md_table(REPOSITORIES, "complete", int(days))
def run_multiple(logger, days): """ Manually specify for which repositories you want to update the data. :param logger: LOGGER object :param days: Number of days (int) for which FIC will generate the changelog.md data tables. """ get_keys("Github") get_keys("Mercurial") new_list = [] while input != "q": print("You have selected : ", new_list) for keys in REPO_LIST: print(REPO_LIST.index(keys) + 1, keys) user_choice = input("Select a repo by typing it's " "number, " "type q when you are done: ") if str(user_choice) == "q": logger.info('========Logging for %s on %s ========', str(new_list).strip('[]'), datetime.now()) for repository in new_list: if repository in REPOSITORIES.get("Github"): create_files_for_git(repository, onerepo=True) generate_main_md_table(REPOSITORIES, "complete", int(days)) elif repository in REPOSITORIES.get("Mercurial"): create_files_for_hg(repository, onerepo=True) clear_file("changelog.md", int(days)) generate_main_md_table(REPOSITORIES, "complete", int(days)) try: new_entry = int(user_choice) - 1 if new_entry < 0 or new_entry >= len(REPO_LIST): print('Choice not valid!') else: new_list.append(REPO_LIST[int(new_entry)]) REPO_LIST.pop(int(new_entry)) except ValueError: exit(0)