I’ve started to move my svn hooks from theory to reality. I’ll fix the earlier post with any corrections I may discover, but here is the main pre-commit script
#!/bin/sh REPOS="$1" TXN="$2" SVNLOOK=/usr/bin/svnlook # All checks passed, so allow the commit. for f in `find $REPOS/hooks/scripts -name "pre-*"` do if [ -x "$f" ] then $f $REPOS $TXN $SVNLOOK if [ $? -eq 0 ] then continue else exit 1 fi fi done exit 0
And here is pre-non-empty.sh which makes sure that the commit message is not blank.
#!/bin/sh #Make sure that the log message contains some text. REPOS=$1 TXN=$2 SVNLOOK=$3 $SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" > /dev/null if [ $? -ne 0 ] then echo "Commit messages cannot be blank" >&2 exit 1 else exit 0 fi
Of course, it doesn’t stop people from keyboard bashing to get around the check, but that will somewhat be handled by other pre-commit scripts and casual monitoring of the log.