def analyze(path, year, out): repositories = discover_repositories(os.path.expanduser(path)) logs = [] for repo in repositories: logs += generate_git_log(repo) log_by_year = sort_by_year(logs) max_commits = [] for y in log_by_year: data = process_log(log_by_year[y], y) max_commits.append(data['max_commits']) if not year: year = y else: year = int(year) global_max = max(max_commits) processed_logs = process_log(log_by_year[year], year) logger.info('Generating report for year {}'.format(year)) if out: with open(out, 'w') as fout: make_svg_report(processed_logs, global_max, fout) else: make_svg_report(processed_logs, global_max)
def test_process_log(): """Ensures process_log() works as intended.""" # Extract logs for the current repository logs = generate_git_log('.') logs2013 = process_log(logs, 2013) assert logs2013['year'] == 2013 assert logs2013['daily_commits_mine'] assert logs2013['daily_commits_others'] == {} assert logs2013['max_commits'] > 0