Question

I have an SVN pre-commit hook that previously resided on a Linux server. I'm now trying to move things over to a Windows (Server 2003) server.

This hook was written in Python, which worked fine on Linux with its #!/usr/bin/env python line at the top. Windows, however, doesn't work that way and requires hooks to be batch files (or other formats, but still not Python).

The important thing is that the arguments get passed to the script and the exit code gets returned to the calling process (the SVN server), so that it knows whether or not to allow the commit. I know next to nothing about .bat file syntax, but I thought that something like this would do the trick:

C:\Python26\python.exe pre-commit.py %1 %2

Am I right in thinking that this is the simplest way to wrap the Python script? Will it automatically return the exit code of the script?

Was it helpful?

Solution

To answer my own question: this almost works. The exit code is detected through the ERRORLEVEL variable, but due to the empty environment, the path to the script must be fully specified. Thankfully the first argument contains the location of the repository, so it's just:

C:\Python26\python.exe %1\hooks\pre-commit.py %1 %2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top