Question

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.

Was it helpful?

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.

OTHER TIPS

Compile your "hook" as a console application, and then write a batch file that calls your console application. The batch file needs to be named correctly and placed in the "hooks" folder of your Subversion repository.

For your specific case, the batch file should be called pre-commit.bat (or pre-commit.cmd).

I had to keep users from commiting to the wrong branch by mistake. So I wrote a pre-commit hook that would check the comment for a key value. If the comment doesn't start with the right key the commit is aborted.

Here is the project: http://sourceforge.net/projects/csvnprecommit/

Feel free to use it as a base for your own hook or use it as is. If you find a bug submit it to the project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top