Skip to content

Instantly share code, notes, and snippets.

@sheepmaster
Forked from evmar/git-graph.sh
Created August 5, 2010 10:07
Show Gist options
  • Save sheepmaster/509508 to your computer and use it in GitHub Desktop.
Save sheepmaster/509508 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)
count=$(git grep -E "$expr" $commit -- '*.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