实现:利用 svn 的 hook 脚本
其实 svn 自带的 pre-commit 脚本模版功能就是禁止没有写log的不能提交。
最简单的方法就是
cp pre-commit.tmpl pre-commit
chmod +x pre-commit
mOo 提供了一个功能更加强大的脚本,看不顺眼你也可以自己修改。
复制以下脚本到你的svn仓库/hooks目录,命名为 pre-commit 并且 +x
#!/bin/sh
# vim:fenc=utf-8
# [1] REPOS-PATH (the path to this repository)
# [2] TXN-NAME (the name of the txn about to be committed)
#
# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
#export LC_ALL=zh_CN.UTF-8
REPOS="$1"
TXN="$2"
TYPE="$3"
if test -z "$TYPE" ; then
TYPE="-t"
fi
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
look() {
$SVNLOOK "$@" "$TYPE" "$TXN" "$REPOS"
}
if look log | grep '.' > /dev/null ; then :; else
echo "必须填写提交日志!" >&2
exit 1
fi
if look changed | grep '^A ' | sed -r 's#^A +##' | grep -iE '\.(ncb|opt|plg|suo|aps|bsc|idb|obj|pcc|pch|pdb|res|sbr|exe|tmp|ilk|o|log|rar|zip|7z)$|^(Debug|Release|Debug_Ts|Release_Ts|Thumbs\.db)$|(^\.)' 1>&2 ; then
echo "你提交的文件中包含不允许提交的文件,比如 rar、zip、7z、编译器产生的临时文件、图片的缩略图等,这些文件请不要提交到版本库!">&2
exit 1
fi
# All checks passed, so allow the commit.
exit 0
用 tortoise 提交时如果提示 Can't convert string from native encoding to 'UTF-8',则需要修改 apache 的runtime locale
编辑apache的启动脚本,debian是 /etc/init.d/apache2
它的默认设置是
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
修改为
ENV="env -i LANG=zh_CN.UTF-8 PATH=/usr/local/bin:/usr/bin:/bin"
保存退出,并重启 apache 即可。

2 条评论:
大哥,ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"这个是在哪里改呀,我的RHEL 5,用 tortoise 提交时提示 Can't convert string from native encoding to 'UTF-8',不知道怎么改,谢谢!
我的是修改 /etc/init.d/apache2
你用的rhel5,应该是 /etc/init.d/httpd
发表评论