Skip to content

Instantly share code, notes, and snippets.

@lukeasrodgers
Last active September 27, 2016 08:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeasrodgers/4700556 to your computer and use it in GitHub Desktop.
Save lukeasrodgers/4700556 to your computer and use it in GitHub Desktop.
Hacky shell script and gnuplot commands to plot the size of a file across a number of git commits, where the name of the file changes but is pattern-matcheable. y-axis data is unique by date.
set xdata time
set timefmt "%Y%m%d"
set offset graph 0.1, graph 0.1, graph 0.1, graph 0.1
plot "temp.data" using 2:1 with lines
#!/bin/bash
COUNTER=1
revisions_back=$1
file_wildcard=$2
while [ $COUNTER -lt $revisions_back ]; do
git checkout -b temp_br HEAD~$COUNTER
# du won't give file size in bytes in OSX...
size=`ls -al public/ | grep $file_wildcard | tr -s ' ' | tr '\t' ' ' | cut -d ' ' -f 5`
sizes[ $COUNTER ]=$size
# get date in YYYYMMDD format
dates[ $COUNTER ]=`git show --format="%ci" HEAD | head -n 1 | cut -c 1-10 | sed 's/-//g'`
commits[ $COUNTER]=`git rev-parse HEAD`
git checkout dev
git branch -D temp_br
let COUNTER=COUNTER+1
done
let COUNTER=1
for i in "${sizes[@]}"; do
# we want to ignore duplicate dates with uniq, so make that the last field
echo "$i ${commits[ $COUNTER ]} ${dates[ $COUNTER ]}" >> temp.temp
let COUNTER=COUNTER+1
done
cat temp.temp | uniq -f 2 > temp.data
rm -f temp.temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment