一、編寫(xiě) 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個(gè)字符! " 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]注釋信息不要遺漏產(chǎn)品編號(hào),如[W-P170122-08],若無(wú)產(chǎn)品編號(hào)請(qǐng)以[A-A000000-00]開(kāi)頭填寫(xiě)備注,謝謝! " 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`這個(gè)統(tǒng)計(jì)長(zhǎng)度。
MSG=`$SVNLOOK log -t "$TXN" "$REPOS"`為日志的內(nèi)容
二、將編輯好文件放到svn服務(wù)器倉(cāng)庫(kù)hooks中,Linux下要確保pre-commit可執(zhí)行的。
三、可以在svn客戶端實(shí)驗(yàn)了,window下可以烏龜客戶端。
以上這篇SVN限制message字符個(gè)數(shù)及格式的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。