Guest User

Untitled

a guest
Jul 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. insertions = 0
  5. deletions = 0
  6. r = re.compile('.* \d+ files changed, (\d+) insertions\(\+\), (\d+) deletions\(-\)')
  7.  
  8. test_match = r.match(' 8 files changed, 220 insertions(+), 1 deletions(-)\n')
  9. assert test_match, test_match
  10. assert 220 == int(test_match.group(1)), test_match.group(1)
  11. assert 1 == int(test_match.group(2)), test_match.group(2)
  12.  
  13. i = 0
  14.  
  15. last_commit = None
  16. for line in os.popen('git log'):
  17. if line.startswith('commit '):
  18. last_commit = line[7:-1]
  19. if line.startswith('Author: chad '):
  20. print last_commit
  21. shortstat = os.popen('git diff --shortstat %s^ %s' % (last_commit, last_commit)).read()
  22. print shortstat
  23. m = r.match(shortstat)
  24. if m:
  25. insertions += int(m.group(1))
  26. deletions += int(m.group(2))
  27.  
  28. print 'Total insertions', insertions, 'Total deletions', deletions
  29.  
  30. i += 1
  31. #if i > 20:
  32. # break
  33.  
  34. print 'Total insertions', insertions
  35. print 'Total deletions', deletions
Add Comment
Please, Sign In to add comment