Skip to content

Instantly share code, notes, and snippets.

@eykanal
Created January 31, 2013 14:26
Show Gist options
  • Save eykanal/4683189 to your computer and use it in GitHub Desktop.
Save eykanal/4683189 to your computer and use it in GitHub Desktop.
Script used to track progress on thesis work. Relies on svn and ploticus.
#!/bin/sh
# move to correct directory
currDir=pwd
cd /Users/eliezerk/Documents/Research-grad/thesis/thesis-tex-svn/
# get current revision
revisions=`svnversion | sed 's/^[A-Z0-9]*://'`
isModified=`echo $revisions | sed -e 's/^[0-9A-Z]*://' -e 's/[0-9]//g'`
if [ "$isModified" = "M" ] ; then
echo "Cannot update table while current version is changed. Please commit changes to SVN, update, and re-run."
exit 1
else
echo "Current revision: $revisions"
fi
# check for log
log=allLog.txt
if [ "$1" = "reset" ]; then
echo "removing current log files, continuing..."
rm $log $graphLog
else
if [ -s $log ] ; then
# check whether log is current... if yes, exit, if not, start from there
i=`tail -n1 $log | awk '{print $3}'`
let i=$i+1
if [ $i -eq $revisions ] ; then
echo "log is current, exiting."
exit 1
fi
echo "log contains up to revision $i, starting from there..."
else
# if no log, start from scratch
echo "no log, starting from first revision..."
i=1
fi
fi
tmpDate=0
# go through revisions
while [ $revisions -gt $i ]
do
let i=$i+1
let j=$i-1
echo "comparing revisions $i and $j... \c"
# get text
date=`svn info -r $j | grep 'Date' | awk '{print $4"."$5}'`
# get date
number=`svn diff -r $j:$i thesis\ writeup.tex | sed -E -e '/^(==|@@|-)/d' -e 's/^\+//' | wc -w`
# append to log
newline="$date $number $j"
lastline=`tail -n1 $log`
if [ "$lastline" != "$newline" ]; then
echo "$date $number $j" >> $log
echo "done."
else
echo "already in log, skipping."
fi
done
echo "Generating plots...\c"
/sw/bin/ploticus -prefab chron data=allLog.txt x=1 y=2 datefmt=yyyy-mm-dd title="Thesis Progress (by svn revision)" xlbl="Revision" ylbl="Words Added/Changed" -png -o "progress.png" mode=bars unittype=datetime outline=color=black ygrid="color=gray(0.9)" autow=yes rectangle="1 1 10 3" -pagesize 13,5
echo " done."
cd $pwd
echo "Complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment