Skip to content

Instantly share code, notes, and snippets.

@klen
Created May 26, 2010 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save klen/414432 to your computer and use it in GitHub Desktop.
Save klen/414432 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import sys
import re
def main(additional=''):
re_author = re.compile(r'^.*?\((.*?)\s*\d{4}-\d{2}-\d{2}.*')
authors = {}
for filename in os.popen('git ls-tree --name-only -r HEAD'):
sys.stderr.write('.')
for line in os.popen('git blame %s HEAD %s' % ( additional, filename )):
if line.startswith('^'):
continue
m = re_author.match(line)
author = m.groups()[0]
if not authors.has_key(author):
authors[author] = 0
authors[author] += 1
m = sum(authors.values())
print '\n%s lines' % m
for name, lines in authors.items():
print '%s: %02.02f (%s lines)' % (name, lines/float(m)*100, lines)
if __name__ == "__main__":
since = ''
if len( sys.argv ) > 1:
since = '--since=%s' % sys.argv[1]
main(since)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment