2013-06-09

GitHub provides code frequency plots that show the number of lines added and removed within a repository over time:

Code frequency plot from GitHub

Here's a quick and dirty method to visualize this information from any local repository in more chronological detail, using the calendarHeat R function from makeR:

git log --format=format:%cd --date=short --shortstat --no-merges master \
| paste - - - | sort --key 1 | sed '$a\\' \
| awk --field-separator "\t" '
$1 != date { print date, ins, del; date = $1; ins = 0; del = 0; }
{ match($2, /([0-9]+) ins/, m); ins += m[1];
match($2, /([0-9]+) del/, m); del += m[1]; }'
\
| r --eval '
library("makeR")
attach(read.table(textConnection(readLines("stdin"))))
png("heatmap.png")
calendarHeat(V1, sapply(pmax(V2, V3), log))'

and the result:

Calendar heatmap of Git repository for Rack

Instead of showing line insertion and deletion counts separately, I've chosen to use the simplified metric of the maximum of the two counts for each commit, and I've colored it on a log scale to accentuate small variations.