cd repository/hooks,找到pre-commit.tmpl文件,去掉后缀.tmpl, 编辑pre-commit文件:
1. windows: 重命名为pre-commit.bat
Java代码
- @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
@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
Java代码 #!/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