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

SVN禁止删除和强制注释操作的钩子脚本 (Linux)

2016-08-24 10:44 393 查看
hooks/pre-commit (记得授权)

REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
# Make sure that the log message contains some text.
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 5 ];
then
echo -e "nLog message cann't be empty! you must input more than 5 chars as comment!." 1>&2
exit 1
fi

SCMLIST="huayu"
C_USER=`$SVNLOOK info -t $TXN $REPOS | sed -n "1p"`
if [ -z `echo $SCMLIST | grep $C_USER` ];then
echo `$SVNLOOK changed -t $TXN $REPOS` > /svn/project/huayu/commit_log
if cat /svn/project/huayu/commit_log|cut -d" " -f1|uniq -u|grep "^D";then
echo "You do not have permisson to delete a file" > /dev/stderr
rm -rf /svn/project/huayu/commit_log
exit 1
fi
fi

#$SVNLOOK log -t "$TXN" "$REPOS" | \
#   grep "[a-zA-Z0-9]" > /dev/null || exit 1

# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
#commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1

# All checks passed, so allow the commit.
exit 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: