日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SVN提交时强制用户写日志

發(fā)布時(shí)間:2024/9/19 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SVN提交时强制用户写日志 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

? 在使用SVN進(jìn)行項(xiàng)目管理的過程中,為了對各版本提交狀況進(jìn)行了解,我們需要在SVN提交過程中強(qiáng)制用戶輸入一定的日志。

下面介紹一下如何來限制用戶SVN提交時(shí)必須輸入日志。

步驟:

?

1、進(jìn)入SVN倉庫的hooks目錄,把pre-commit.tmpl文件重命名為pre-commit

?

2、修改pre-commit文件

修改前:

REPOS="$1" TXN="$2" # Make sure that the log message contains some text. SVNLOOK=/usr/bin/svnlook $SVNLOOK log -t "$TXN" "$REPOS" | \ grep "[a-zA-Z0-9]" > /dev/null || exit 1 # Check that the author of this commit has the rights to perform # the commit on the files and directories being modified. commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1 # All checks passed, so allow the commit. exit 0

修改后:

REPOS="$1" TXN="$2" # Make sure that the log message contains some text. SVNLOOK=/usr/bin/svnlook #$SVNLOOK log -t "$TXN" "$REPOS" | \ # grep "[a-zA-Z0-9]" > /dev/null || exit 1 # Check that the author of this commit has the rights to perform # the commit on the files and directories being modified. #commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1 LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c` if [ "$LOGMSG" -lt 10 ];#要求注釋不能少于10個(gè)字符 then echo -e "\n注釋不能為空,且字?jǐn)?shù)必須大于10個(gè)字符." 1>&2 exit 1 fi # All checks passed, so allow the commit. exit 0

其實(shí)就是把源文件中的以下3行進(jìn)行注釋:

$SVNLOOK log -t "$TXN" "$REPOS" | \ grep "[a-zA-Z0-9]" > /dev/null || exit 1 commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1

然后添加以下幾行命令:

LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c` if [ "$LOGMSG" -lt 10 ];#要求注釋不能少于10個(gè)字符 then echo -e "\nLog message cann't be empty! you must input more than 10 chars as comment!." 1>&2 exit 1 fi

3、把pre-commit文件修改為755

chmod 755 pre-commit

修改完后,測試了一下,在沒有輸入日志時(shí)提交SVN,提示錯(cuò)誤

Commit failed (details follow): Commit blocked by pre-commit hook (exit code 1) with output: 注釋不能為空,且字?jǐn)?shù)必須大于10個(gè)字符

輸入一定的字?jǐn)?shù)后提交成功!

?

這里的錯(cuò)誤提示可以修改echo 里面輸出的內(nèi)容:

echo -e "\nLog message cann't be empty! you must input more than 10 chars as comment!。" 1>&2

總結(jié)

以上是生活随笔為你收集整理的SVN提交时强制用户写日志的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。