# !/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