Handy Hack for Git refugees in Subversion land
Posted by Alec The Geek on 23 November 2012
When you’re a Git user working on a project using Subversion (SVN) using the Git SVN client is a great option, I’ve been using it for the last twelve months and it works really well. However sometimes it’s not quite good enough when things like Ant scripts are written for SVN.
My colleagues use TortoiseSVN. which among other things provides support for standard commit message templates. This uses a SVN property called “
tsvn:logtemplate“, is a specific feature of ToirtoiseSVN and it not standard in the SVN client. Git has a simliar feature using the config value
commit.template and it’s standard on the
Today I wrote an
svn wrapper script to provide the standard template feature to the command line SVN client. You may find it useful. It’s written for OS X and assumes you have Git configured and SVN Installed via Mac Homebrew — however it will be trivial to modify it for your environment,
The script does does a number of things:
- It passes all SVN sub-commands, except commit, to svn without change
- It checks all the arguments to if the commit message has already been supplied (run the command and exit)
- It checks to see if the ”tsvn:logtemplate” is set
- If the TortoiseSVN template is not set then it attempts to find the Git template
- If that fails then it falls back to an internal template
- The template is placed in a file and another message file
- The user is prompted to edit the message file
- The updated message file is checked against the template — if the user has not made a change the commit is aborted
- The svn client is called with the message file.
Updated March/2013 – Somehow an stupid bug crept in. Now squashed.
I have added a new feature when using
- Check if the working copy has uncommitted changes. NB Files that are not registered are ignored in this check
- Abort the
update if files are already modified
Sorry, the comment form is closed at this time.