Last active
December 15, 2015 18:33
-
-
Save radimklaska/3963664 to your computer and use it in GitHub Desktop.
Easy git stats in one command
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 --author="Radim Klaska" --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n",add,subs,loc }' - | |
# returns: "added lines: XXX removed lines: XXX total lines: XXX" | |
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";}' | |
# returns: jar.smahel,: 35 files changed, 1206 insertions(+), 118 deletions(-), 1088 net | |
# radim,: 18 files changed, 433 insertions(+), 373 deletions(-), 60 net | |
# Author: http://stackoverflow.com/a/20414465 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Originaly from http://codeimpossible.com/2011/12/16/Stupid-Git-Trick-getting-contributor-stats/
I just don't want to forget it... :)