svn強制提交備註信息

當咱們用tortoisesvn,提交代碼時,有不少人不喜歡寫註釋的,代碼版本多了,根本搞不清,哪一個版本改了什麼東西?因此若是加一些註釋的話,咱們看起來,也方便不少。因此在提交的時候,我會強制要求,寫註釋。若是對svn的安裝配置不怎麼了解,請參考:linux svn安裝和配置,不結合apache
1, cd /home/administrator/www/svn_test svn_test是一個代碼倉庫
2,mv ./hooks/pre-commit.tmpl ./hooks/pre-commit 將代碼倉庫根目錄下,hooks文件夾中的pre-commit.tmpl文件重命名爲pre-commit
3,vim ./hooks/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 
 
# Exit on all errors. 
set -e 
 
# Check that the author of this commit has the rights to perform 
# the commit on the files and directories being modified. 
"$REPOS"/hooks/commit-access-control.pl "$REPOS" $TXN \ 
 "$REPOS"/hooks/commit-access-control.cfg 
 
# 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 
 
LOGMSG=`$SVNLOOK log -t $TXN $REPOS | wc -m`       //定義個變量,注意這裏不是單引號 
 
#$SVNLOOK log -t "$TXN" "$REPOS" | \               //把這一行和下面的一行註釋掉 
# grep "[a-zA-Z0-9]" > /dev/null || exit 1 
 
echo $LOGMSG > /home/administrator/www/aaa.txt     //爲了測試變量用的,查看$LOGMSG有沒有值,最後要註釋掉 
if [ "$LOGMSG" -lt 48 ]                            //這裏爲何是48呢,一個漢字對應16個字符 
then 
 echo "\n至少輸入4個漢字" >&2                        //必須填四個漢字 
 exit 1 
fi 
 
# Exit on all errors. 
#set -e 
 
# Check that the author of this commit has the rights to perform 
# the commit on the files and directories being modified. 
#"$REPOS"/hooks/commit-access-control.pl "$REPOS" $TXN \    //把這一行和下面的一行註釋掉。 
#  "$REPOS"/hooks/commit-access-control.cfg 
 
# All checks passed, so allow the commit. 
exit 0 
4,保存後,咱們要給pre-commit這個文件,加可執行權限chmod +x pre-commit,有一點在說一下就是$SVNLOOK 前面的不是單引號,具體shell語法,請參考shell在線手冊
相關文章
相關標籤/搜索