diff --git a/bin/commit-counter b/bin/commit-counter new file mode 100755 index 0000000..a79a53d --- /dev/null +++ b/bin/commit-counter @@ -0,0 +1,41 @@ +#!/usr/bin/env python +import argparse +import datetime +import jinja2 +import os +import subprocess +import teamanalysis.git +import teamanalysis.repos +import teamanalysis.time +import webbrowser + +def _get_commits(repo, start, end): + abspath = '/Users/eliribble/src/{}/'.format(repo) + os.chdir(abspath) + command = [ + 'git', + 'log', + '--pretty=format:"%h %aI"', + '--after={}'.format(start.isoformat()), + '--before={}'.format(end.isoformat())] + output = subprocess.check_output(command) + return output + +def _show_summary(timepoint): + start, end = teamanalysis.time.get_checkpoint(timepoint) + results = {} + for repo in teamanalysis.repos.REPOSITORIES: + output = _get_commits(repo, start, end) + lines = output.split('\n') + results[repo] = len(lines) if output else 0 + #print("{0:<30}: {1}".format(repo, results[repo])) + print("{}\t{}\t{}".format(start.date().isoformat(), end.date().isoformat(), sum(results.values()))) + +def main(): + timepoint = datetime.datetime(2014, 1, 1, 0, 0, 1) + while timepoint < datetime.datetime.utcnow(): + _show_summary(timepoint) + timepoint = timepoint + datetime.timedelta(days=7) + +if __name__ == '__main__': + main()