Add initial function for counting commits over time periods

This just starts at the beginning of 2014 and cranks through
This commit is contained in:
Eli Ribble 2015-07-30 15:14:24 -06:00
parent c605fe7622
commit 6c78e686ee
1 changed files with 41 additions and 0 deletions

41
bin/commit-counter Executable file
View File

@ -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()