Subversion Edge默认禁用了hook模版的编辑功能。
如何启用编辑功能呢?
参考:https://liumiaocn.blog.csdn.net/article/details/108212661
启用pre-commit
在Subversion Edge中,进入版本库,选中pre-commit模版,点击rename按钮,将pre-commit.tmpl修改为pre-commit,点击OK按钮并保存,该pre-commit便生效了。
但是在提交文件时,报如下错误:
svnlook: E160043: Expected FS format between '1' and '4'; found format '6'
环境:
- Subversion Edge 5.2.4
- TortoiseSVN-1.14.1.29085-x64-svn-1.14.1
问题解决:因为我的环境使用yum install -y svn
安装过一次SVN,而我在pre-commit
中指定的SVNLOOK
的路径/usr/bin/svnlook
是通过yum安装svn,不是Subversion Edge
安装的svn,因此修改SVNLOOK
的路径为/opt/svn/csvn/bin/svnlook
,修改后解决该问题。
限制提交文件大小及提交注释不能为空
#!/bin/sh
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/opt/svn/csvn/bin/svnlook
LOG_INFO=`$SVNLOOK log -t "$TXN" "$REPOS"`
if [ _"$LOG_INFO" = _"" ]; then
echo "---please add commit message!---" 1>&2
exit 1
fi
# check file size
files=`$SVNLOOK changed -t "$TXN" "$REPOS" | awk '{print $2}'`
MAX_SIZE=5242880
for f in $files
do
filesize=`$SVNLOOK cat -t $TXN $REPOS $f | wc -c`
if [ "$filesize" -gt "$MAX_SIZE" ]
then
echo "---The submitted file must < 100MB---" 1>&2
exit 1
fi
done
# All checks passed, so allow the commit.
exit 0
参考:https://blog.csdn.net/liumiaocn/article/details/81942161
https://liumiaocn.blog.csdn.net/article/details/108212661
https://liumiaocn.blog.csdn.net/article/details/108212582
网友评论