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

前端 未结 4 697
心在旅途
心在旅途 2020-12-14 16:41

I\'m using Visual SVN Server and Tortoise SVN (client) for source control. I would like all developers to standardize on a consistent format for checkin notes.

For

4条回答
  •  难免孤独
    2020-12-14 17:12

    Or, for further SVN_EDITOR comfort (e.g. properly linking to the TFS work item in the case of having to use SvnBridge), one could store the following script as ~/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 "${@}"
    

    and then simply do

    export SVN_EDITOR=~/bin/svn_editor
    

    in ~/.bashrc or some such. Bonus points for keeping the work item number file updated even from the current work item page as viewed in Firefox TFS web interface (I think there possibly is a way to communicate with Firefox to get page titles etc.). Or simply have this script start a first initial editor run on the persistent work item file and then let it do the second editor run on the customized commit template.

提交回复
热议问题