首页 文章

如何创建SVN提交消息模板和挂钩以进行验证

提问于
浏览
24

我正在使用Visual SVN Server和Tortoise SVN(客户端)进行源代码管理 . 我希望所有开发人员都能以一致的格式标准化签到笔记 .

例如,我希望他们的提交消息默认为......

概要:

开发者名称:(预先填充)

评论人:

[错误ID]:

[更改错误状态]:

已知的问题:

受影响的文件:(预先填充)

在将来,我希望[Bug Id]和[Bug State]提供信息,以触发Bug跟踪系统的自动更新 . 还应使用svn用户和用户提交的文件预填充开发人员名称和受影响的文件 .

请发送您可能拥有的任何链接或样本 .

4 回答

  • 1

    我发现它使用: Folder right-click -> Properties -> New... -> Advanced -> Property name: tsvn:logtemplate -> enter a Property value -> OK -> OK.

  • 4

    使用命令行执行此操作的方法是更改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"
    
  • 30

    或者,为了进一步提高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通信以获取页面 Headers 等) . 或者只是让这个脚本启动在持久性工作项文件上运行的第一个初始编辑器,然后让它在自定义提交模板上运行第二个编辑器 .

  • 1

    取自How to create a Tortoise SVN Checkin Template(修改为适合更新版本):

    可以根据项目要求自定义日志模板,并可用于实现严格的日志格式 . 将此添加到您的svn存储库很简单:选择要应用它的SVN文件夹转到Subversion属性(右键单击TortoiseSVN - >属性)选择新建 - >高级,然后从名为属性名称的下拉列表中选择tsvn:logtemplate . 将上述模板(或您自己的模板)添加到组合框下方的文本区域 . 如果要将该属性应用于当前文件夹下面的层次结构中的每个文件和文件夹,请选中“递归”复选框 . 单击“确定”将该属性添加到列表中 . 签入所有文件夹和文件,以便团队中的其他人都可以使用相同的模板 .

相关问题