def history(location, model, filename, deployment, custom_config): """Generate a report over a model's git commit history.""" if model is None: raise click.BadParameter("No 'model' path given or configured.") if location is None: raise click.BadParameter("No 'location' given or configured.") try: repo = git.Repo() except git.InvalidGitRepositoryError: LOGGER.critical( "The history report requires a git repository in order to check " "the model's commit history.") sys.exit(1) previous = repo.active_branch repo.heads[deployment].checkout() try: manager = managers.SQLResultManager(repository=repo, location=location) except (AttributeError, ArgumentError): manager = managers.RepoResultManager( repository=repo, location=location) config = ReportConfiguration.load() # Update the default test configuration with custom ones (if any). for custom in custom_config: config.merge(ReportConfiguration.load(custom)) history = managers.HistoryManager(repository=repo, manager=manager) history.load_history(model, skip={deployment}) report = api.history_report(history, config=config) previous.checkout() with open(filename, "w", encoding="utf-8") as file_handle: file_handle.write(report)
def history(directory, filename, index): """ Generate a report over a model's git commit history. DIRECTORY: Expect JSON files corresponding to the branch's commit history to be found here. Can also be supplied via the environment variable MEMOTE_DIRECTORY or configured in 'setup.cfg' or 'memote.ini'. """ try: repo = git.Repo() except git.InvalidGitRepositoryError: LOGGER.critical( "The history report requires a git repository in order to check " "the current branch's commit history.") sys.exit(1) api.history_report(repo, directory, filename, index)
def history(location, model, filename, deployment, custom_config): """Generate a report over a model's git commit history.""" callbacks.git_installed() LOGGER.info("Initialising history report generation.") if location is None: raise click.BadParameter("No 'location' given or configured.") try: repo = git.Repo() except git.InvalidGitRepositoryError: LOGGER.critical( "The history report requires a git repository in order to check " "the model's commit history.") sys.exit(1) LOGGER.info("Obtaining history of results from " "the deployment branch {}.".format(deployment)) repo.git.checkout(deployment) try: manager = managers.SQLResultManager(repository=repo, location=location) except (AttributeError, ArgumentError): manager = managers.RepoResultManager(repository=repo, location=location) config = ReportConfiguration.load() # Update the default test configuration with custom ones (if any). for custom in custom_config: config.merge(ReportConfiguration.load(custom)) LOGGER.info("Tracing the commit history.") history = managers.HistoryManager(repository=repo, manager=manager) history.load_history(model, skip={deployment}) LOGGER.info("Composing the history report.") report = api.history_report(history, config=config) with open(filename, "w", encoding="utf-8") as file_handle: file_handle.write(report)
def history(location, filename, index): """ Generate a report over a model's git commit history. DIRECTORY: Expect JSON files corresponding to the branch's commit history to be found here. Or it can be an rfc1738 compatible database URL. Can also be supplied via the environment variable MEMOTE_DIRECTORY or configured in 'setup.cfg' or 'memote.ini'. """ try: repo = git.Repo() except git.InvalidGitRepositoryError: LOGGER.critical( "The history report requires a git repository in order to check " "the current branch's commit history.") sys.exit(1) try: manager = managers.SQLResultManager(location) except (AttributeError, ArgumentError): manager = managers.RepoResultManager(location) api.history_report(repo, manager, filename, index)
def test_history_report_file(history_directory, tmpdir): filename = tmpdir.join("index.html") api.history_report(None, history_directory, filename) assert exists(filename)