Skip to content

Instantly share code, notes, and snippets.

@cameronmaske
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronmaske/f6de9cb18010a130d523 to your computer and use it in GitHub Desktop.
Save cameronmaske/f6de9cb18010a130d523 to your computer and use it in GitHub Desktop.
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