Created
April 14, 2017 09:48
-
-
Save yuan3y/1f7f297ca17f29670963a5d48f6dd967 to your computer and use it in GitHub Desktop.
Get number of lines added and deleted per day from your git repo
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
#!/bin/bash | |
ds() { | |
date --date="$1 days ago" +%Y-%m-%d | |
} | |
BRANCH=master # your branch here | |
echo "Date,LinesAdded,LinesDeleted" | |
for day in $(seq 1 10) | |
do | |
lines=$(git --no-pager log --after=$(ds $day) --before=$(ds $(($day - 1))) --format=format: --numstat $BRANCH | awk '{s+=$1; t+=$2;} END {printf "+%s,-%s",$1,$2}') | |
if [[ "$lines" != "+,-" ]]; then | |
echo "$(ds $day),$lines" | |
else | |
echo "$(ds $day),0,0" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I forked it to take the script and number of days as an argument.
I also had trouble with the awk command on line 12 - I replaced
$1,$2
withs,t
at the end.