-
-
Save anonymous/3e8003c84e7655966bc5 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 | |
import sys | |
from subprocess import Popen, PIPE | |
from os import path | |
filename = 'gitoutput.txt' | |
commit_old = raw_input("Enter the original commit ID: ") | |
commit_new = raw_input("Enter the new commit ID: ") | |
git_command = "/usr/bin/git diff " + commit_old + ".." + commit_new + " --word-diff=porcelain > " + filename | |
git_query = Popen(git_command, shell=True, stdout=PIPE, stderr=PIPE) | |
output = git_query.communicate()[0] | |
f=open(filename,'r') | |
newwords=0 | |
delwords=0 | |
for lines in f: | |
f1=lines.split() | |
try: | |
f2=f1[0] | |
f3=f2[0] | |
if f3=='+': | |
newwords=newwords+len(f1) | |
elif f3=='-': | |
delwords=delwords+len(f1) | |
except: | |
print "Line not counted (either empty or contains unchanged words)" | |
f.close() | |
networds=newwords-delwords | |
print 'new words:', str(newwords) | |
print 'deleted words:', str(delwords) | |
print 'net additions:', str(networds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment