1、强制写log信息的脚本
配置pre-commit文件,要求用户每次更新文件都必须写log.
# cd /usr/local/svn/project/hooks/
# vim pre-commit
文件内容如下:
#!/bin/shl
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 6 ];
then
echo -e "\Commit aborted,please input log information at least 6 characters" 1>&2
exit 1
fi
配置完成后,给本件加上可执行权限。再提交代码时,就必须按要求写至少六个字符的注释了.
2、可修改log脚本
配置pre-revprop-change文件,此文件在show log中修改log时会运行,得到修改的权限,否则会报错:DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent. At least one property change failed; repository is unchanged
# cd /user/local/svn/project/hooks/
# vim pre-revprop-change
文件内容如下:
REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
if ["$PROPNAME" = "svn:log"];then exit 0;fi
exit 1
配置完后加可执行权限生效。
3、在自动编译时,如果某目录正在编译,则禁止开发往该目录提交文件
pre-commit
###############################
REPOS="$1"
TXN="$2"
RES="OK"
st="k2/branch/BR-K2-1_0_001_20100316/"
ABSUSER=$($SVNLOOK author $REPOS -t $TXN)
if [ $ABSUSER != "ads" ]
then
if [ "`echo $files|grep $st`" = "$files" ]
then
echo -e "\n The Path $st Is Being Build Now,Please Commit Later" 1>&2
exit 1
fi
fi
exit 0
###############################
自动构建的脚本 会去sed这个pre-commit里面的st变量。就可以达到类似的效果。
4.禁止新增大于100M的文件入库(为了防止开发提交二进制码入库所做限制)
pre-commit
########################################
REPOS="$1"
TXN="$2"
RES="OK"
MAX_SIZE=10240000
files=$($SVNLOOK changed -t $TXN $REPOS |grep "^A "|awk '{print $2}')
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)" >> /dev/stderr
exit 1
fi
done
########################################
阅读(813) | 评论(0) | 转发(0) |