Question

Need a little help with svn post-commit batch script. Here what I have:

post-commit.bat:

1. @ECHO OFF
2. cd D:\Subversion\...\hooks
3. SET OUTPUT = default
4. FOR /F "tokens=*" %%a in ('revision.bat') do ( SET OUTPUT=%%a )
5. findstr /m "Autobuild" D:\Subversion\...\db\revprops\0\%OUTPUT%
6. if %errorlevel%==0 (
7.   call website.bat
8. )

website.bat:

D:\Subversion\...\hooks\wget http://website.com/service-trigger

revision.bat:

svnlook youngest D:\Subversion\...

So, what is happening here is that

  1. After commit to repository, the script extracts the last revision number

  2. Uses that number to find a file in revision logs

  3. Try to find a particular string in that log

  4. If the particular string exists, fire some URL

My problem is that this script is executed when calling directly from cmd, but when SVN calls it, seems that something weird happens in line #5, because i do not get any error, but line #7 is never called.

I suspect that maybe i should run script as Administrator, but since I had never seriously programmed for Windows, I am not sure and I need some help

Was it helpful?

Solution

Spaces are significant in SET statements. In line 3, you are setting a variable "output " not "output"

Remove the spaces around the = in line 3 and after the %%a in line 4 (but cosmetic only here.)

Also - not clear whether ... is (omitted) or (parent-of-parent). If absolute filename contains spaces, "quote it"

Could also be that your starting directory is different for each invocation. The cd on line 2 changes the current directory on the D: drive, but does not affect the default drive. You'd need to execute D: to switch the default to drive D:. revision.bat on line 4 is relative to the default.

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