Created
September 18, 2019 09:01
-
-
Save erizhang/546df48c5e8be4ba3ce57b32a9836b6f to your computer and use it in GitHub Desktop.
One awk script to format the output of git log to statistics the file change and LoC insertions/deletions
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
#git log --shortstat --since="1 Jan, 2019" > log.txt | |
BEGIN { | |
commit=""; | |
date=""; | |
file=0; | |
add=0; | |
del=0; | |
} | |
{ | |
if (index($1, "commit")!=0) | |
commit=$2; | |
if (index($1, "Date:")!=0) | |
date=sprintf("%s %s, %s", $3, $4, $6); | |
if (index($3, "changed")!=0){ | |
file=$1; | |
if(index($0, "insertions")!=0 && index($0, "deletions")!=0){ | |
add=$4; | |
del=-$6; | |
} | |
else { | |
if(index($0, "insertions")!=0) | |
add=$4; | |
else | |
del=-$4 | |
} | |
printf("%s;%s;%s;%s;%s\n", commit,date,file,add,del); | |
file=0; | |
add=0; | |
del=0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment