Skip to content

Instantly share code, notes, and snippets.

@zackmdavis
Created May 29, 2014 03:39
Show Gist options
  • Save zackmdavis/1c144e531b5eb26f7123 to your computer and use it in GitHub Desktop.
Save zackmdavis/1c144e531b5eb26f7123 to your computer and use it in GitHub Desktop.
counting SwiftStackers' contributions to Swift
from collections import Counter
import subprocess
import re
# run in a clone of git@github.com:openstack/swift.git
# thanks to http://stackoverflow.com/a/13687302
blame_output = subprocess.check_output('''git ls-tree --name-only -z -r HEAD | egrep -z -Z -E '\.py$' | xargs -0 -n1 git blame --line-porcelain | grep "^author " | sort | uniq -c | sort -nr''', shell=True)
number_regex = re.compile("(\d+)")
swiftstack_peeps = ["Samuel Merritt", "Clay Gerrard", "John Dickinson", "Darrell Bishop", "Jon Snitow", "Leah Klearman", "Joe Arnold"]
swiftstack_counts = {p: 0 for p in swiftstack_peeps}
total_lines = 0
for listing in blame_output.split('\n'):
try:
lines_here = int(number_regex.search(listing).group(0))
except:
continue
total_lines += lines_here
for p in swiftstack_peeps:
if p in listing:
swiftstack_counts[p] += lines_here
break
print swiftstack_counts
print "GRAND PERCENTAGE", float(sum(v for k, v in swiftstack_counts.items()))/total_lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment