Wednesday, January 28, 2009

SVN commit hook

If you need to enforce certain patterns in commit messages for svn (eg. ticket nos etc) create a script in ~repos/hooks/pre-commit :

REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text of form Feedback nnnnn:

SVNLOOK=/usr/local/bin/svnlook
match=`$SVNLOOK log -t "$TXN" "$REPOS" | grep -i 'feedback.*[0-9]:'| wc -c`
if [ $match -eq 0 ]
then
echo "COMMIT HAS FAILED:Log message does not contain feedback number eg. feedback nnnn: commit message" 2>&1
exit 1
else
exit 0
fi

exit 0

No comments: