views:

58

answers:

2

Hello Everyone,

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.

A: 

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).

Mark
+1  A: 

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 http://stackoverflow.com/questions/2074891/how-to-access-file-information-in-a-pre-commit-hook-using-sharpsvn/2075198#2075198 for some examplecode.

Bert Huijben