Last active
January 25, 2018 19:58
-
-
Save steinybot/60cc7bd759925ad7bf04e45625778511 to your computer and use it in GitHub Desktop.
Git insertions and deletions
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
git log --shortstat --format="%an" | sed '/^$/d' | awk ' | |
BEGIN { FS = ", " } | |
{ | |
if (match($1, /^ [0-9]+ files? changed/)) { | |
split($2, a, " ") | |
inserts = (a[1] == "")? 0 : a[1] | |
split($3, b, " ") | |
deletes = (b[1] == "")? 0 : b[1] | |
total = (inserts - deletes) | |
print name " " inserts " " deletes " " total | |
} else { | |
name = $0 | |
} | |
}' | sort | awk ' | |
{ | |
name = $1 | |
for (i = 2; i <= (NF - 3); i++) { | |
name = name " " $i | |
} | |
if (name == previous) { | |
inserts = inserts + $(NF - 2) | |
deletes = deletes + $(NF - 1) | |
total = total + $NF | |
} else if (previous != "") { | |
print total ", " previous ", " inserts ", " deletes ", " total | |
grandTotal = grandTotal + total | |
inserts = $(NF - 2) | |
deletes = $(NF - 1) | |
total = $NF | |
} | |
previous = name | |
} | |
END { | |
print grandTotal ", Total, -, -," grandTotal | |
} | |
' | sort -rn | cut -d " " -f 2- | column -t -s, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This version doesn't quite work properly. I get different totals for three different commands: