Sunday 10 August 2014

Show Commits To SVN Branch

This script is designed to show a number of recent commits to the users current SVN branch in an easy readable format.
I'm up for criticism on this as I'm not a huge fan of the amount of if statements...
#!/bin/bash
NUM=$1
URL=`(cd /home/path/to/workspace ; svn info |grep '^URL:' | sed -e 's/^URL: //')`

txtylw=$(tput setaf 3)
txtgrn=$(tput setaf 2) 
txtblu=$(tput setaf 4)
txtbld=$(tput bold)
txtrst=$(tput sgr0)

if [ -n "$1" ]; then
 echo "${txtbld}${txtylw} Showing you the last $1 commits to $URL ${txtrst}"
 echo "________________________________________________________________________" 
svn log --verbose --limit $1 $URL | while read line; do
if [[ $line == "M /"* ]]; then
 echo "${txtbld}${txtblu} $line ${txtrst}"
else if [[ $line == "A /"* ]]; then
 echo "${txtbld}${txtgrn} $line ${txtrst}"
else if [[ $line == "---"* ]]; then
 echo "${txtbld} $line ${txtrst}"
else if [[ $line == "r"[0-9]* ]]; then
 echo "${txtgrn}${txtbld} $line ${txtrst}"
else
echo "$line"
fi
fi
fi
fi

done
else
 echo "Please provide a limit parameter! (e.g 10)"
fi

No comments:

Post a Comment