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

4

25

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 Example I want their Commit Message to default to...

Synopsis:

Developer Name: (pre-populated)

Reviewed By:

[Bug Id]:

[Change Bug State]:

Known Issues:

Affected Files: (pre-populated)

In the future I'd like [Bug Id] and [Bug State] to supply the information to trigger an automated update to the Bug Tracking system. Also Developer Name and Affected Files should be prepopulated with the svn user and files that the user is commiting.

Please send any links or samples you may have.

Abound answered 11/6, 2009 at 19:9 Comment(1)
"Affected Files", and perhaps also "Developer Name", should not be in the commit message because they are reliably in the built-in commit metadata.Cephalometer
A
33

Taken from How to create a Tortoise SVN Checkin Template (modified to fit to more current versions):

The log template can be customized as per the project requirements and can be used to implement strict log format.

Adding this to your svn repository is easy :

  1. Select a SVN folder to which you want to apply this go to Subversion properties( right click TortoiseSVN -> Properties)

  2. Select New -> Advanced, then tsvn:logtemplate from the drop down list named Property name.

  3. Add the above templates(or your own) to text area below combo box.

  4. If you want to apply the property to every file and folder in the hierarchy below the current folder, check the Recursive checkbox.

  5. Click on OK to add that property to the list.

  6. Check-in all the folders and files so that everyone else in your team can use the same template.

Abound answered 24/6, 2009 at 3:27 Comment(3)
Was a bit difficult to find, but guess that's to be expected near 4 years later :) I found it using: Folder right-click -> Properties -> New... -> Advanced -> Property name: tsvn:logtemplate -> enter a Property value -> OK -> OK. The recursive option didn't seem to matter, either in applying or removing this templated property value. Thank you very much adrainbanks (even 4 years hence!).Knut
The recursive option only matters if you don't check out the root folder (where the property was set only). All tsvn properties are client properties, so no communication to the server is done to read the properties.Holler
Link rot. New link: tortoisesvn.net/docs/release/TortoiseSVN_en/…Somerville
Q
4

A way to do this with the command line is to change the SVN_EDITOR environment variable, described here:

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"
Quinate answered 3/2, 2010 at 19:22 Comment(0)
B
1

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.

Borderline answered 12/4, 2012 at 15:32 Comment(0)
S
1

I found it using: Folder right-click -> Properties -> New... -> Advanced -> Property name: tsvn:logtemplate -> enter a Property value -> OK -> OK.

Singly answered 14/12, 2015 at 7:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.