Minimum SVN Log Message Length

Update 2010-04-07: Stefan Küng, TortoiseSVN lead developer, commented that you can simply set the tsvn:logminsize property on your folders and the commit button in TortoiseSVN will be disabled until the log message contains at least as many characters as the value of the property.

While working on the Stars-Nova project at SourceForge.net we wanted to prevent developers from accidentally making commits to Subversion (SVN) without providing a log message. Sometimes developers simply forget to enter a log message, leaving the rest of the team in the dark as to what changes they have made to the repository. You can diff the modified files to try to figure out what they have done, but a short message in the revision log would save you that time. Even experienced developers might on occasion slip and commit with an empty message. Luckily SF.net allows you to correct the log message after the commit has been made (command line: svn propset svn:log "new log message" -r80 --revprop <repository URL>), but that might not be the case for your choice of SVN hosting provider. It might take a while before the developer who forgot to enter the message is made aware of the issue and can correct it so we would rather get the commit right the first time around and save us the trouble.

SVN allows arbitrary server-side scripts to be configured to run on various events (pre-commit, post-commit, etc.). These script hooks offer a lot of flexibility and would have been a good place to centrally enforce a non-empty log message policy. However, because of security reasons SF.net, and all other SVN hosting providers I know of, does not allow user-defined server-side hook scripts. Instead SF.net provides a short list of predefined scripts and a check on log message length is not among the scripts that are included. I have submitted a feature request at SF.net suggesting that they add a server-side hook script such as this and I encourage you to vote for it.

Most of the developers on Stars-Nova use TortoiseSVN and this SVN client just happens to support client-side hook scripts. Based on that I wrote a small script (mmm… JScript) that prevents the user from accidentally executing a commit without providing a message. Currently it does not trim leading and trailing spaces, new lines or other non-printable characters before the character count is checked. However, the minimum character count can be configured so that an accidental space or new line (new lines are composed of two characters: carriage return and line feed) will also stop the commit.

Usage:

  1. Make sure you have a recent version of TortoiseSVN (min. v1.5).
  2. Open the TortoiseSVN Settings dialog (right-click a folder in Windows Explorer > TortoiseSVN > Settings).
  3. Go to “Hook Scripts” and click “Add…”.
  4. Choose Hook Type: Pre-Commit Hook
  5. Set the Working Copy Path to the directory (or any parent directory) where you checked out your working copy from SVN. “C:\” works as well if you want this script to always execute when you run commit on working copies located anywhere on your C drive.
  6. Set Command Line To Execute: WScript <path to script>\MinMessageLength.js
  7. Ensure that “Wait for script to finish” is checked.
  8. Ensure that “Hide the script while running” is checked.
  9. (Optional) Configure the minimum number of characters allowed by changing  the MIN_CHARACTERS variable in the script.

Download the TortoiseSVN client-side hook script