Skip to content

Instantly share code, notes, and snippets.

@evmar
Created August 5, 2010 00:16
Show Gist options
  • Save evmar/509017 to your computer and use it in GitHub Desktop.
Save evmar/509017 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Given a grep expression, create a graph of occurrences of that expression
# in your code's history.
set -e
expr="$1"
datafile=$(mktemp)
echo 'ago count' > $datafile
for ago in $(seq 90 -1 0); do
echo -n '.'
commit=$(git rev-list -1 --until="$ago days ago" origin/trunk)
git checkout -q -f $commit
count=$(git grep -E "$expr" -- '*.cc' '*.h' '*.m' '*.mm' | wc -l)
echo "-$ago $count" >> $datafile
done
R CMD BATCH <(cat <<EOF
data = read.delim("$datafile", sep=' ')
png(width=600, height=300)
plot(count ~ ago, type="l", main="$expr", xlab='days ago', data=data)
EOF
) /dev/null
echo done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment