Created
May 26, 2010 12:53
-
-
Save klen/414432 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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