一、编写 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字符个数及格式的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。