I’ve just spent several days procrastinating about exactly this question. There are third party products available and plenty of PERL and Python scripts but I wanted something simple and a language I was familiar with so ended up just writing hooks in a C# console app. It’s very straight forward:
public void Main(string[] args)
{
string repositories = args[0];
string transaction = args[1];
var processStartInfo = new ProcessStartInfo
{
FileName = "svnlook.exe",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = String.Format("log -t \"{0}\" \"{1}\"", transaction, repositories)
};
var p = Process.Start(processStartInfo);
var s = p.StandardOutput.ReadToEnd();
p.WaitForExit();
if (s == string.Empty)
{
Console.Error.WriteLine("Message must be provided");
Environment.Exit(1);
}
Environment.Exit(0);
}
You can then invoke this on pre commit by adding a pre-commit.cmd file to the hooks folder of the repo with the following line:
[path]\PreCommit.exe %1 %2
You may consider this overkill but ultimately it’s only a few minutes of coding. What’s more, you get the advantage of the .NET language suite which IMHO is far preferable to the alternatives. I’ll expand my hooks out significantly and write appropriate tests against them as well – bit hard to do this with a DOS batch file!
BTW, the code has been adapted from this post.