We've got VisualSVN Server set up as our Subversion server on Windows, and we use Ankhsvn + TortoiseSVN as clients on our workstations.
How can you configure the server to require commit messages to be non-empty?
We've got VisualSVN Server set up as our Subversion server on Windows, and we use Ankhsvn + TortoiseSVN as clients on our workstations.
How can you configure the server to require commit messages to be non-empty?
Here's a Windows Shell JScript that you can use by specifying the hook as:
It's pretty easy-to-read, so go ahead an experiment.
BTW, the reason to do this in JScript is that it does not rely on any other tools (Perl, CygWin, etc.) to be installed.
VisualSVN Server 3.9 provides the
VisualSVNServerHooks.exe check-logmessage
pre-commit hook that helps you reject commits with empty or short log messages. See the article KB140: Validating commit log messages in VisualSVN Server for instructions.Besides the built-in
VisualSVNServerHooks.exe
, VisualSVN Server and SVN in general uses a number of hooks to accomplish tasks like this.start-commit
— run before commit transaction begins, can be used to do special permission checkingpre-commit
— run at the end of the transaction, but before commit. Often used to validate things such as a non zero length log message.post-commit
— runs after the transaction has been committed. Can be used for sending emails, or backing up repository.pre-revprop-change
— runs before a revision property change. Can be used to check permissions.post-revprop-change
— runs after a revision property change. Can be used to email or backup these changes.You need to use the
pre-commit
hook. You can write it yourself in just about any language your platform supports, but there are a number of scripts on the web. Googling "svn precommit hook to require comment" I found a couple that looked like they would fit the bill:We use the excellent CS-Script tool for our pre-commit hooks so that we can write scripts in the language we're doing development in. Here's an example that ensures there's a commit message longer than 10 characters, and ensures that .suo and .user files aren't checked in. You can also test for tab/space indents, or do small code standards enforcement at check-in, but be careful making your script do too much as you don't want to slow down a commit.
Prior to adding commit hooks to my server, I just distributed svnprops to the TortoiseSVN clients.
So, as an alternative:
In TortoiseSVN -> Properties property name - add/set
tsvn:logminsize
appropriately.This of course is no guarantee on the server as clients/users can opt not to do it, but you can distribute svnprops files if you like. This way, users don't have to set their own values - you can provide them to all users.
This also works for things like bugtraq: settings to link issue tracking stuff in the logs.
What VisualSVN offers you to enter as hooks are "Windows NT command scripts", which are basically batch files.
Writing if-then-else in batch files is very ugly and probably very hard to debug.
It will look something like the following (search for pre-commit.bat) (not tested):
You need a grep.exe on the path, %1 is the the path to this repository, %2 the name of the txn about to be committed. Also have a look at the pre-commit.tmpl in the hooks directory of your repository.