The idea behind sending emails on every svn commit is basically to help developers review their peer's code, which improves both awareness of the global codebase and overall code quality since errors might be picked up and go or bad coding practices can be identified and discussed between the developers.

While we have had svn post-commit hooks set up for a while at Liip for some of our bigger projects, the case of smaller ones that occupy very small teams remained problematic. The main issue being that configuring the classic post-commit hooks requires intervention on the svn server, to which not everybody has access, and since small projects might change often this can be annoying both for the sysadmins and for the developers that have to depend on someone every time they want a new svn directory to be watched.

The idea we came up with is to use svn properties as the configuration for the post-commit hook, so that anyone with commit access can set it up, and it can easily be applied to any number of directories.

The script looks up through the parent directories of every modified/added files in a commit, with a svn propget liip:review call, and once one is found, the value of the property is used as the email “To:” address(es). This means you can easily have an entire project being watched by someone, but some particular sub-directory of it will only be watched by some other persons, for example if you want to extract the xsl commits out of a php okapi project you would just add another liip:review property on the themes directory.

It is fully configurable if you want to try it for yourself, you basically need to give it the svn server url and the property to check for, then some other extras are available. To allow easy filtering in mail clients the mails sent contain a X-SVN-Commit-Mail header with the value being the name of the repository. Also the subject contains the committer name, revision and watched-paths affected.

You can get the script off of our public svn repository at svn.liip.ch/repos/public/misc/svnwatch – the dispatch-emails.php script uses the svn binary and the dispatch-emails-ext.php uses pecl's svn extension for php if you prefer.