SVN限制message字符个数及格式的实例
程序员文章站
2022-03-18 11:56:59
一、编写 pre-commit脚本
------------------------------------
#/bin/bash
repos="$1"...
一、编写 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字符个数及格式的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。