簡體   English   中英

如何創建SVN提交消息模板並進行鈎子驗證

[英]How do I create a SVN Commit Message Template and Hook to Verify

我正在使用Visual SVN Server和Tortoise SVN(客戶端)進行源代碼控制。 我希望所有開發人員都能對簽入說明的格式進行標准化。

例如,我希望他們的提交消息默認為...

概要:

開發人員名稱:( 預填充)

審核人:

[錯誤ID]:

[更改錯誤狀態]:

已知的問題:

受影響的文件:( 預填充)

將來,我希望[Bug Id]和[Bug State]提供信息以觸發對Bug跟蹤系統的自動更新。 另外,開發人員名稱和受影響的文件也應使用svn用戶和該用戶提交的文件預先填充。

請發送您可能擁有的任何鏈接或樣品。

取自“ 如何創建Tortoise SVN簽入模板” (已修改以適合最新版本):

日志模板可根據項目要求進行定制,並可用於實施嚴格的日志格式。

將此添加到您的svn存儲庫很容易:

  1. 選擇要應用到的SVN文件夾,然后轉到Subversion屬性(右鍵單擊TortoiseSVN -> Properties

  2. 選擇tsvn:logtemplate New -> Advanced ,然后從名為Property name的下拉列表中選擇tsvn:logtemplate

  3. 將以上模板(或您自己的模板)添加到組合框下方的文本區域。

  4. 如果要將屬性應用於當前文件夾下層次結構中的每個文件和文件夾,請選中“遞歸”復選框。

  5. 單擊OK以將該屬性添加到列表中。

  6. 檢入所有文件夾和文件,以便團隊中的其他所有人都可以使用相同的模板。

使用命令行執行此操作的一種方法是更改​​SVN_EDITOR環境變量,如下所述:

http://svn.haxx.se/dev/archive-2006-02/0487.shtml

SVN_EDITOR="rm svn-commit.tmp && cp $REPOS/hooks/log.tmpl svn-commit.tmp && vi svn-commit.tmp"

或者,為了進一步提高SVN_EDITOR的舒適度(例如,在必須使用SvnBridge的情況下正確鏈接到TFS工作項),可以將以下腳本存儲為〜/ bin / svn_editor:

#!/bin/sh

template_file="${@}"
template_file_new="${template_file}.new"

current_work_item_number_file="${HOME}/tfs_work_item_number_current.txt"
[ -f "${current_work_item_number_file}" ] && work_item=$(cat "${current_work_item_number_file}") || work_item="please fill in!"

# Yes folks, this is the TFS convention (hard, NOT-TO-BE-ALTERED text)
# to properly link to work items via SvnBridge commits!
work_item_prefix_hard_tfs_convention_text="work item: "

work_item_text="${work_item_prefix_hard_tfs_convention_text}${work_item}"

custom_text="${work_item_text}\n\n[this addition above initially placed to ignored content part here,\nto ensure properly abortable empty message by default - please move it to active content as needed]"

sed -e 's/\(will be ignored--\)/\1\n'"${custom_text}"'/' "${template_file}" > "${template_file_new}"

mv -f "${template_file_new}" "${template_file}"

$EDITOR "${@}"

然后簡單地做

export SVN_EDITOR=~/bin/svn_editor

在〜/ .bashrc或類似的文件中。 獎勵點,即使在Firefox TFS Web界面中查看時,也可以從當前工作項目頁面更新工作項目編號文件(我認為可能存在與Firefox進行通信以獲得頁面標題等的方法)。 或者只是讓此腳本啟動在持久性工作項文件上運行的第一個初始編輯器, 然后讓它在定制的提交模板上運行第二個編輯器。

我使用以下方法找到它: Folder right-click -> Properties -> New... -> Advanced -> Property name: tsvn:logtemplate -> enter a Property value -> OK -> OK.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM