Last active
October 3, 2015 21:12
-
-
Save andmarios/62237b22cad1ee88af16 to your computer and use it in GitHub Desktop.
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 | |
# Marios Andreopoulos, 2015 | |
# A very simple bash script that goes into a git directory, counts lines of code | |
# for a certain language and each commit and creates a plot. | |
# $1 is path to git repository, $2 is language name as supported by cloc (e.g Go, Bourne Shell) | |
# bash linesPerCommitPlot.sh my-repo Go | |
# NEVER run it in your work directory. Make a temporary clone and use it there. | |
CURRENT="$(pwd)" | |
echo "files,language,blank,comment,code" > lineCommit-stats.csv | |
pushd $1 | |
for i in $(git rev-list --reverse HEAD); do | |
git checkout $i -- | |
cloc --csv --include-lang=$2 --quiet . | tail -n1 >> "$CURRENT"/lineCommit-stats.csv | |
done | |
REPO="$(basename $(pwd))" | |
popd | |
cat <<EOF | gnuplot | |
set terminal pdf size 8, 5 color enh | |
set output "$REPO-lines-stats.pdf" | |
set datafile separator "," | |
set xlabel 'commit' | |
set ylabel 'lines (#)' | |
set y2label 'files (#)' | |
set title "$REPO — $2 lines per commit" | |
set grid ytics | |
show grid | |
set xrange [1:*] | |
show xrange | |
#set autoscale xmax xfixmin | |
set yrange [0:] | |
set ytics nomirror | |
set y2tics | |
set y2range [0:] | |
set style line 1 lt 1 lw 3 pt 7 pi 0 ps 0.6 | |
set pointintervalbox 1.5 | |
set key left top | |
set key invert | |
set boxwidth 0.5 relative | |
set style fill solid | |
plot 'lineCommit-stats.csv' u (\$0+1):1 ti col with boxes axes x1y2 lc rgb "#E0F8F7",\ | |
'' u (\$0+1):3 ti col with linespoints ls 1 lc rgb "gray75",\ | |
'' u (\$0+1):4 ti col with linespoints ls 1 lc rgb "#FE642E",\ | |
'' u (\$0+1):5 ti col with linespoints ls 1 lc rgb "#74DF00" | |
EOF | |
rm -f lineCommit-stats.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment