SVN限制message字符个数及格式的实例
发布时间:2021-03-21 18:52:48 所属栏目:安全 来源:网络整理
导读:一、编写 pre-commit脚本 ------------------------------------#/bin/bashREPOS="$1"TXN="$2"# Make sure that the log message contains some text.SVNLOOK=/usr/bin/svnlookLOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`MSG=
一、编写 pre-commit脚本 ------------------------------------ #/bin/bash REPOS="$1" TXN="$2" # Make sure that the log message contains some text. SVNLOOK=/usr/bin/svnlook LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c` MSG=`$SVNLOOK log -t "$TXN" "$REPOS"` echo $LOGMSG #check log message more than 15_chars if [ "$LOGMSG" -le 15 ]; then # echo -e "[Commit]log message cann't be empty! YOU MUST input more than 20_chars as comment! " 1>&2 echo -e "[Commit]注释信息不能为空且不少于15个字符! " 1>&2 exit 1 fi #if [[ "$MSG" == "["*"]"* ]]; if [[ "$MSG" == "["[A-Z]-[A-Z][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9]"]"* ]]; then exit 0 # echo -e "[Commit]log message cann't be empty! YOU MUST input more than 20_chars as comment! " 1>&2 else echo -e "[Commit]注释信息不要遗漏产品编号,如[W-P170122-08],若无产品编号请以[A-A000000-00]开头填写备注,谢谢! " 1>&2 exit 1 fi # All checks passed,so allow the commit. exit 0 ----------------------------------------- 其中SVNLOOK要注意路径,LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`这个统计长度。 MSG=`$SVNLOOK log -t "$TXN" "$REPOS"`为日志的内容 二、将编辑好文件放到svn服务器仓库hooks中,Linux下要确保pre-commit可执行的。 三、可以在svn客户端实验了,window下可以乌龟客户端。 以上这篇SVN限制message字符个数及格式的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程小技巧。 (编辑:佛山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |