Created
June 7, 2014 19:15
-
-
Save srigi/f81ce80d5c5c8f815e40 to your computer and use it in GitHub Desktop.
cloc statistics by commit
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/bash | |
startCommit=$2 | |
initialCommit=`git rev-parse HEAD` # commit of the repository before we start the work | |
file='cloc-stats.csv' | |
# use sed to remove duplicate lines with commit ID, git-rev-list not fully accepting my format, arrrgh | |
if [[ $1 = "--help" || $1 = "-h" ]]; then | |
echo "Generate 'cloc per commit' stats from a GIT repository by following the parent links from the given commit." | |
echo "" | |
echo "Usage: cloc-history [commit-id]" | |
echo "" | |
exit | |
fi | |
if [[ -z $1 ]]; then | |
startCommit='HEAD' | |
fi | |
history=`git rev-list --reverse --author="Igor Hlina" --date=short --pretty="format:%h %cd" HEAD | sed '/commit .*/d' | awk '{if(d!=$2){d=$2; print $1}}'` | |
echo "date files blank comment code" > $file | |
for commitId in $history; do | |
git checkout -q $commitId | |
commitDate=`git log -n1 --date=short --pretty='format:%cd' | cut -c 1-${COLUMNS+10}` | |
commitStats=`cloc --force-lang="CoffeeScript",coffee --quiet * | awk '/SUM/'| sed "s/SUM:/$commitDate/"` | |
echo "$commitStats" | |
echo "$commitStats" >> $file | |
done; | |
git checkout -q $initialCommit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment