我可以访问SVN服务器,并在目录 /home/.svn1/hooks
找到 pre-commit.tmpl我相信这是我要更改的文件,禁止使用中文消息进行提交
文件内容为:
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/local/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || exit 1
# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
# All checks passed, so allow the commit.
exit 0
如何过滤掉中文字符?
答案 0 :(得分:1)
不要更改提交消息。如果可能,您可能会改变消息的含义。 更好的方法是防止任何违反规则的提交消息,在您的情况下使用中文字符。
如果有人使用禁用字符,用户将看到一条消息,提交将被拒绝。
这可以通过预提交挂钩轻松完成。
因此,在 .svn / hooks文件夹中创建预提交文件。
使用svnlook
检查提交的不同参数。
做一个svnlook -h
来看看还能做些什么。
一个简单的例子,检查是否有任何字符不在ASCII范围内:
#!/bin/sh
REPOS="$1"
TXN="$2"
FOUND=$(svnlook log -t "$TXN" "$REPOS" | tr -d '\n' | grep "[^\x00-\x7F]" )
if [ "$FOUND" != "" ]
then
exit 0
else
echo "Reject commit! Do not use non ASCCI in commit messages!" 1>&2 && exit 1
fi