Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- insertions = 0
- deletions = 0
- r = re.compile('.* \d+ files changed, (\d+) insertions\(\+\), (\d+) deletions\(-\)')
- test_match = r.match(' 8 files changed, 220 insertions(+), 1 deletions(-)\n')
- assert test_match, test_match
- assert 220 == int(test_match.group(1)), test_match.group(1)
- assert 1 == int(test_match.group(2)), test_match.group(2)
- i = 0
- last_commit = None
- for line in os.popen('git log'):
- if line.startswith('commit '):
- last_commit = line[7:-1]
- if line.startswith('Author: chad '):
- print last_commit
- shortstat = os.popen('git diff --shortstat %s^ %s' % (last_commit, last_commit)).read()
- print shortstat
- m = r.match(shortstat)
- if m:
- insertions += int(m.group(1))
- deletions += int(m.group(2))
- print 'Total insertions', insertions, 'Total deletions', deletions
- i += 1
- #if i > 20:
- # break
- print 'Total insertions', insertions
- print 'Total deletions', deletions
Add Comment
Please, Sign In to add comment