SVN限制message字符个数及格式的实例
一、编写 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下可以乌龟客户端。
相关推荐
ECSHOP专属建设 2020-11-13
xzjforDream 2020-09-23
fenggit 2020-09-15
起点 2020-08-17
leehbhs 2020-07-26
leehbhs 2020-07-04
pub_svnserve.conf的 pub_authz.conf的配置文件有非法字符的原因引起,需要查找pub_authz.conf提的非法内容比如多余的空格删除或直接将pub_authz.conf
起点 2020-06-28
leehbhs 2020-06-20
dingqinghu 2020-06-16
dengweijunkedafu 2020-06-09
nebulali 2020-05-27
起点 2020-05-10
起点 2020-05-05
83520298 2020-05-04