如何設定SVN版本控制工具必須寫注釋才能提交

來源:互聯網
上載者:User

如何設定SVN版本控制工具必須寫注釋才能提交: 

當我們用tortoisesvn等SVN工具提交代碼時,有很多人不喜歡寫注釋的而直接提交,這樣一來代碼版本多了,根本搞不清,哪個版本改了什麼東西?所以如果加一些注釋的話,我們看起來,也方便很多。所以在提交的時候,我會強制要求,寫注釋。如果對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手冊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.