Alec the Geek

Reflections on software and related things from an older geek

  • Twitter Ramplings

  • My Bookmarks

  • RSS Alec’s GitHub

    • An error has occurred; the feed is probably down. Try again later.

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 git client.

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:

  1. It passes all SVN sub-commands, except commit, to svn without change
  2. It checks all the arguments to if the commit message has already been supplied (run the command and exit)
  3. It checks to see if the ”tsvn:logtemplate” is set
  4. If the TortoiseSVN template is not set then it attempts to find the Git template
  5. If that fails then it falls back to an internal template
  6. The template is placed in a file and another  message file
  7. The user is prompted to edit the message file
  8. The updated message file is checked against the template — if the user has not made a change the commit is aborted
  9. The svn client is called with the message file.

Updated March/2013 – Somehow an stupid bug crept in. Now squashed.
Updated Jan/2013
I have added a new feature when using svn update:

  1. Check if the working copy has uncommitted changes. NB Files that are not registered are ignored in this check
  2. Abort the update if files are already modified

YMMV

About these ads

Sorry, the comment form is closed at this time.

 
Follow

Get every new post delivered to your Inbox.

Join 272 other followers

%d bloggers like this: