Skip to content

Instantly share code, notes, and snippets.

@miikka
Last active August 10, 2017 14:59
Show Gist options
  • Save miikka/3ab4bb4b24f87ed6023a8cb76610823c to your computer and use it in GitHub Desktop.
Save miikka/3ab4bb4b24f87ed6023a8cb76610823c to your computer and use it in GitHub Desktop.
Cumulative committer count data from a git repo
#!/usr/bin/env python3
# git log --format="%ae,%at" | python cumulative.py
from datetime import date
import fileinput
committers = dict()
for line in fileinput.input():
author, time = line.split(",")
# Warning: the comparison is a string comparison, not a number comparison
if author not in committers or committers[author] > time:
committers[author] = time
ac = 0
print("date,count,author")
for author, time in sorted(committers.items(), key=lambda x: x[1]):
ac = ac + 1
d = date.fromtimestamp(int(time))
print("%s,%s,%s" % (d, ac, author))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment