svn禁止删除权限和日志长度限制的脚本书写

来源:互联网 发布:网络公司简介怎么写 编辑:程序博客网 时间:2024/05/16 07:04

svn服务器分window版本和linux版本。

方法都是修改pre-commit脚本。

1、linux下脚本示例

REPOS="$1"  
TXN="$2"  
  
# Make sure that the log message contains some text.  
SVNLOOK=/usr/bin/svnlook  
  
if [ -z `$SVNLOOK log -t "$TXN" "$REPOS" |grep "[a-zA-Z0-9]"` ];then  
        echo "nLog message cann't be empty! you must input more than 5 chars as comment!." >&2  
    exit 1  
fi  
USER=`$SVNLOOK author -t $TXN $REPOS`  
ADMINLIST=admin,helijie  
if  [ "`echo $ADMINLIST|grep -w $USER|wc -l`" -eq 0 ];then  
    if [ `$SVNLOOK changed -t $TXN $REPOS |grep "^D "|wc -l` -gt 0 ];then  
        echo "You Don't have the pemmision of delete!Please contact your administrator!" >&2           
        exit 1  
    fi  
fi  
exit 0  


2、window下bat脚本示例

@echo off

setlocal

set REPOS=%1

set TXN=%2

rem check that logmessage contains at least 10 characters

rem .....代表5个字符

svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul

if %errorlevel% gtr 0 goto err

exit 0

:err

echo Empty log message not allowed. Commit aborted! 1>&2

exit 1