Created
January 10, 2014 14:39
-
-
Save tomviner/8355234 to your computer and use it in GitHub Desktop.
Git when last changed dict
This file contains hidden or 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 subprocess | |
from collections import defaultdict | |
def latest(): | |
filesdict = {} | |
changecount = defaultdict(int) | |
stringlist = subprocess.check_output(["git","ls-files"]).split("\n") | |
statlist = subprocess.check_output(["git","whatchanged"]).split("\n") | |
for line in statlist: | |
if line.startswith("Date"): | |
temp = line[8:] | |
if line.startswith(':'): | |
_ , file_name = line.split('\t',1) | |
changecount[file_name] += 1 | |
if file_name not in filesdict: | |
filesdict[file_name] = temp | |
return filesdict, changecount | |
def pretty(filesdict, changecount): | |
for k, v in sorted(filesdict.items(), key=lambda x: changecount[x[0]]): | |
print "Filename: {}".format(k) | |
print "Date: {}".format(v) | |
print "Changes: {}".format(changecount[k]) | |
if __name__ == '__main__': | |
filesdict, changecount = latest() | |
pretty(filesdict, changecount) |
This file contains hidden or 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
from subprocess import Popen, PIPE | |
from collections import defaultdict | |
mycmd = ['git', 'log', '--pretty="%at"', "--name-only"] | |
data_stream = Popen(mycmd, stdout=PIPE) | |
for line in data_stream.stdout: | |
line = line.strip() | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment