Last active
August 29, 2015 14:13
-
-
Save cameronmaske/f6de9cb18010a130d523 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import commands | |
import json | |
output_name = "commits-over-time" | |
data = [] | |
past_changes = {} | |
commits = commands.getstatusoutput( | |
"git rev-list --all master")[1].split('\n') | |
for commit in commits: | |
commands.getstatusoutput("git checkout %s" % commit) | |
timestamp = commands.getstatusoutput("git show -s --format=%ct")[1] | |
file_changes = commands.getstatusoutput( | |
"find . -name '*.py' | xargs wc -l")[1].split('\n') | |
changes = {} | |
for _file in file_changes: | |
if 'total' in _file or len(_file) == 0: | |
continue | |
count, filename = _file.strip().split(' ./') | |
changes[filename] = int(count) | |
if changes: | |
if past_changes != changes: | |
data.append({ | |
'id': commit, | |
'timestamp': int(timestamp), | |
'files': changes | |
}) | |
past_changes = changes | |
commands.getstatusoutput("git checkout master") | |
with open("%s.json" % output_name, 'w') as outfile: | |
json.dump(data, outfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment