In the entry Subversion on Windows as a Service, plus Commit Hook and Backup Script I showed a batch file for hooking into the post commit event of a repository. This batch file annoyed me from the very beginning. During the Indigo Community Day on Thursday in Munich I decided that it was about time to get rid of it, and after yesterday's party, I thought it might be a nice pinky exercise to do the basic port to C# today.
And yes, it is very basic at the moment. All you need to do is take post-commit.exe and post-commit.exe.config from the \SvnPostCommitHook\Hook directory in the downloadable zip file and drop those two into the hooks directory of your repository. The .config file is your ticket to customization:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SvnLookPath" value="C:\Program Files\Subversion\bin\svnlook" />
<add key="MailTo" value="commitlist@yourdomain.com" />
<add key="MailFrom" value="commithook@yourdomain.com" />
<add key="MailSubject" value="Your project name rev {0}, {1}" />
<add key="MailServer" value="localhost" />
</appSettings>
</configuration>
Just as the batch file, post-commit.exe's task is to read the change log and commit message, and post it to a mailing list that distributes the information to the project stakeholders. Therefore, you need to configure the four Mail* settings to match your configuration and preferences. The SvnLookPath needs to point to your Subversion installation, however, most installations should be fine with this default.
How can you test the operation of post-commit.exe? This is the syntax:
post-commit <repository> <revision>
For example:
post-commit e:\subversion\fidalgo 1830
In the current version, testing is highly recommended as no logging or exception handling is implemented.
SvnPostCommitHook1.0.0.50409.zip (12.07 KB)
The source code is BSD-licensed. Future plans are to fully parse the svnlook output, as well as add a logging infrastructure to easily find configuration problems during normal operations of your Subversion server.