Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@j6s
Created March 4, 2016 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j6s/ad810a2a6f8c5be2c31b to your computer and use it in GitHub Desktop.
Save j6s/ad810a2a6f8c5be2c31b to your computer and use it in GitHub Desktop.
#!/bin/bash
# http://stackoverflow.com/a/20414465
git log --shortstat --pretty="%cE" |
sed 's/\(.*\)@.*/\1/' |
grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' |
sort |
sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' |
awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment