#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook #根据自己的svnlook目录填写
# check that logmessage contains at least 10 alphanumeric characters
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 10 ];#10是限制多少个字符
then
echo -e "/nEmpty log message not allowed. Commit aborted!" 1>&2
#上面这句作用是当提交失败时,输出的提示信息
exit 1
fi
把以上代码写入到pre-commit.
注意:
1.hooks目录下没有pre-commit,只有pre-commit.tmpl,把其改成pre-commit
2.给pre-commit添加执行权限:chmod +x pre-commit
3.每建一个项目,都要把pre-commit文件复制一份到项目的hooks目录下,并给于执行权限。