您的位置:首页 > 运维架构 > Shell

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

2017-06-01 15:33 417 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell bat svn delete log