4 ms·
I'd like to see that script.
by taybin 13y ago
I'd like to see that script.
- rav 13y agoHere is a sample implementation: git log --author=rav --numstat --no-merges --pretty=format: | awk -e '{ a += $1; b += $2; } END { print a; print b; print a-b; }' produces this output (sum additions, sum deletions, net line additions): 112529 85383 27146
- zwegner 13y agoHa, nice, there's two options that definitely would've simplified my code (--numstat and --no-merges).
- porges 13y agoTo count by author: git log --numstat --no-merges --pretty=format:%an | awk ' author == "" { author = $0; next } /^$/ { author = ""; next } { added[author] += $1; removed[author] += $2 } END { for (author in added) { print author, "added", added[author], "removed", removed[author], "sum", added[author]-removed[author] } }' | sort -n -k 7
- taybin 13y agoThat is great! Thank you.
- zwegner 13y agoUnfortunately I forgot to grab it off my work laptop when I got laid off. I would've liked to have stuck it up on github... It wasn't really all that tricky though, it took me a few hours to write. git-log has options for only displaying the status line of diff-stat for each commit, and then displaying the parents of each commit, and the author. You look to see that there's only one parent (so it's not a merge), parse out the X added, Y deleted numbers, and stick them in a dictionary keyed by name. A lot of the script was just getting statistics like average/min/max/stddev line counts, and printing them nicely.