Skip to content

Commit

Permalink
add scripts directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Oct 26, 2013
1 parent 4c84851 commit 0cde7eb
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions scripts/count_git_changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import sys

insertions=0
deletions=0
files=0
FROMVER=""
if len(sys.argv)>1:
FROMVER=sys.argv[1]
TOVER=""
if len(sys.argv)>2:
TOVER=sys.argv[2]
TMPNAME=os.tmpnam()
VER=""
if len(FROMVER)>0:
VER=FROMVER+'..'
if len(TOVER)>0:
if len(VER)==0:
VER='..'
VER=VER+TOVER

os.system('git log --oneline --shortstat %s >%s' % (VER,TMPNAME))
for line in file(TMPNAME).readlines():
if line.find('file') == -1:
continue
if line.find('changed') == -1:
continue
if line.find('insertion') == -1 and line.find('deletion') == -1:
continue

entries=line.split(',')
for e in entries:
if e.find('file') != -1:
files+=int(e.strip().split(' ')[0])
elif e.find('insertion') != -1:
insertions+=int(e.strip().split(' ')[0])
elif e.find('deletion') != -1:
deletions+=int(e.strip().split(' ')[0])

print "Files changed: %d" % files
print "Insertions: %d" % insertions
print "Deletions: %d" % deletions

os.unlink(TMPNAME)

0 comments on commit 0cde7eb

Please sign in to comment.