pre-commit 钩子功能:
[[email protected] hooks]# cat /application/svndata/sadoc/hooks/pre-commit
#!/bin/bash
#Check message lenth ---更新版本时强制输入信息小于5个字符会退出
REPOS="$1"
TXN="$2"
logmsg=`svnlook log -t $TXN $REPOS |grep "[a-zA-Z0-9]"|wc -c`
if [ $logmsg -lt 5 ];then
echo $logmsg 1>&2
echo -e "\nLog message is too short" >&2
exit 3
fi
#Check upload filesize ---检查文件大小
MAX_SIZE=1024000 ---阈值
SVNLOOK=/usr/bin/svnlook
files=$($SVNLOOK changed -t $TXN $REPOS |grep "^A "|awk ‘{print $2}‘)
---取出状态是添加的文件列表(A:表示添加)
for f in $files
do
filesize=$($SVNLOOK cat -t $TXN $REPOS $f | wc -c) ---判断大小
if [ $filesize -gt $MAX_SIZE ];then
echo "The new add file $f is too large (must <= $MAX_SIZE)" >&2
exit 1
fi
done
exit 0
记得加上执行权限哦~~
下面是有关各命令的参数详细解释和别的一些东西。。。
http://www.subversion.org.cn/svnbook/1.4/svnbook.html
http://www.subversion.org.cn/svnbook/nightly/svn.ref.svnlook.c.cat.html