Created
July 30, 2014 20:05
-
-
Save Igosuki/c7ff2a22a435edc161d5 to your computer and use it in GitHub Desktop.
Git stats
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
#!/bin/sh | |
AUTHOR=$1 | |
function gitstats { | |
git log --author="$1" --oneline --numstat --pretty=tformat: --after=$2 --before=$3 | sort -f | uniq -c | sort -n | |
} | |
function gitlines { | |
git log --author="$1" --pretty=tformat: --numstat --after=$2 --before=$3 | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' - | |
} | |
function loopprojects { | |
for directory in `ls -d */` | |
do | |
cd $directory | |
echo $directory | |
gitstat= gitstats $1 $after $before | |
#echo `$gitstat | cut -f9 -d " "` | |
cd .. | |
done | |
} | |
function linesforprojects { | |
for directory in `ls -d */` | |
do | |
cd $directory | |
echo $directory | |
gitstat= gitlines $1 $after $before | |
#echo `$gitstat | cut -f9 -d " "` | |
cd .. | |
done | |
} | |
sDateTs=`date -j -f "%Y-%m-%d" $2 "+%s"` | |
eDateTs=`date -j -f "%Y-%m-%d" $3 "+%s"` | |
weekly=604800 | |
monthly=$(($weekly*4)) | |
function loopdates { | |
dateTs=$sDateTs | |
while [ "$dateTs" -le "$eDateTs" ] | |
do | |
nextDateTs=$(($dateTs+$weekly)) | |
after=`date -j -f "%s" $dateTs "+%Y-%m-%d"` | |
before=`date -j -f "%s" $nextDateTs "+%Y-%m-%d"` | |
echo "Between $after and $before" | |
eval $1 $AUTHOR | |
dateTs=$nextDateTs | |
done | |
} | |
loopdates "loopprojects" | |
loopdates "linesforprojects" | |
after=`date -j -f "%s" $sDateTs "+%Y-%m-%d"` | |
before=`date -j -f "%s" $eDateTs "+%Y-%m-%d"` | |
echo "Total of all projects betwwen $after and $before" | |
linesforprojects $AUTHOR | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment