I am using TortoiseSVN on Windows 7 x64.
I tried to put a
post-commit.bat in the
hooks folder of a repository, but it doesn't work at all. So I tried to put a
pre-commit.bat (the content is exact the same as
hooks, and it worked fine.
This is very strange. The .bat file is very simple, I just tried with:
xcopy C:\a C:\b\ /S /F
Anyone makes post-commit work with TortoiseSVN?
The issue isn't a TortoiseSVN issue, but a server issue. Where is the repository stored? What server are you using? Are you using
I take it that your commit happens anyway. There are several possibilities:
Your hook is being executed, but not doing anything. As long as it exits with a zero exit status, Subversion thinks everything is hunky. Try a Subversion program called
pre-commit.bat that contains only the line
exit 2. If you can still commit stuff, your hook isn't working at all.
Your hook isn't being executed. Subversion executes the program
pre-commit in the
hooks directory. There is an environment variable called
PATHEXT on Windows that contains the suffixes that will be appended to a file in order to find the executable. Usually, it tries
*.exe and then
*.bat. If there is a
pre-commit.cmd in that
hooks directory, your
pre-commit.bat won't be executed. Check the value of
PATHEXT for the user executing your Subversion server, and make sure it is set correctly.
One of the issues is that Subversion's hooks eat STDOUT and will only display STDERR only when the hook fails. This makes hooks pretty uncommunicative for the user, and if you're depending upon printing output while executing, you may get the felling that your hook isn't doing anything.
Print stuff to STDERR and not STDOUT. Have a way to force a hook to fail, so you can see STDERR if you need to.
I also don't recommend writing hooks in batch script on Windows. It simply isn't cut out to do this type of work. Use Python or Perl. Or, if you are really that PC oriented and don't want to install Python or Perl on your server, use PowerShell which is a very powerful, but underutilized programming language for Windows.