1. windows: 重命名为pre-commit.bat
@echo off setlocal set REPOS=%1 set TXN=%2 rem check that logmessage contains at least 10 characters rem .....代表5个字符 svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul if %errorlevel% gtr 0 goto err exit 0 :err echo Empty log message not allowed. Commit aborted! 1>&2 exit 1
2. linux:chmod u+x pre-commit
#!/bin/sh REPOS="$1" TXN="$2" SVNLOOK=/usr/bin/svnlook # check that logmessage contains at least 10 alphanumeric characters LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | tr -d ' ' | wc -c` if [ "$LOGMSG" -lt 10 ]; then echo -e "\nEmpty log message not allowed. Commit aborted!" 1>&2 exit 1 fi