Search code examples
c#svntortoisesvnsharpsvnpre-commit-hook

Pre-commit hooks in C# with SharpSVN


I'm new to SharpSVN (and frankly--pretty new to C# as well). I've been trying get a simple pre-commit hook working which checks for a comment. (i.e. the commit fails in the absence of a comment)

There are several posts (like this one) which are related and helpful, but I have a few fundamental questions that are keeping me from getting further:

1) How do I get code like the link above running in C#? (i.e. which C# context would I use-- console application? csharp class?)

2) In a Windows Server context, how do I call my compiled C# program?

I've tried this answer's methodology with no luck.

Thanks in advance.


Solution

  • If you are creating a pre-commit hook you should call it pre-commit.exe. (Subversion accepts hook with the extensions .exe, .cmd, .bat and .wsf.)

    Hooks communicate via stdout, stderr and in some cases stdin, so you should compile your application as a console application.

    To get the hook working you must place the .exe (and the required DLLs) in the hooks directory of the repository.

    See How to access file information in a pre-commit hook using SharpSVN for some examplecode.