Skip to content

Instantly share code, notes, and snippets.

@bblanchon
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bblanchon/48702b151a500eddd001 to your computer and use it in GitHub Desktop.
Save bblanchon/48702b151a500eddd001 to your computer and use it in GitHub Desktop.
GIT: build a CSV with the number of file vs time
#!/bin/bash
OUTPUT=stats.csv
[ -f $OUTPUT ] || echo "date;sln;proj;cs;cpp" > $OUTPUT
count() {
git ls-tree -r --name-only $COMMIT | grep -e $1 | wc -l | sed 's/ //g'
}
git log --pretty="%H %cd" --date=short | while read COMMIT DATE
do
[ "$PREV_DATE" == "$DATE" ] && continue
echo $DATE
PREV_DATE="$DATE"
SLN_COUNT=$(count ".*\.sln$")
echo " $SLN_COUNT solutions files"
PROJ_COUNT=$(count ".*\.[a-z]*proj$")
echo " $PROJ_COUNT project files"
CS_COUNT=$(count ".*\.cs$")
echo " $CS_COUNT C# files"
CPP_COUNT=$(count ".*\.\(c\|cpp\|cc\|h\|hpp\|hh\)$")
echo " $CPP_COUNT C/C++ files"
echo "$DATE;$SLN_COUNT;$PROJ_COUNT;$CS_COUNT;$CPP_COUNT" >> $OUTPUT
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment