Domanda

In some cases it's required to perform a post-commit operation only if some condition is met.

E.g. to send an e-mail only when the committed revision affects '/tags' directory. I've searched the web for such script sample to run in Windows environment and wasn't able to find any so I had to write it myself.

È stato utile?

Soluzione

The post-commit.bat code:

REM The command checks whether the committed revision changes any data under '/tags'
"%VISUALSVN_SERVER%bin\svnlook.exe" dirs-changed %1 --revision %2 | findstr /b "[Tt]ags"

REM If 'findstr' returns error code 0, it means that the commit involves the '/tags' directory.
REM So if the the returned code is 0 the command runs external batch 'post-commit-run.bat'
If %ERRORLEVEL% EQU 0 call %~dp0post-commit-run.bat %*

Altri suggerimenti

I have a post commit Watcher script that will do exactly what you're asking. It's a Perl script, but you can download Perl for Windows from ActiveState or from the Strawberry Perl project.

My post-commit hook is in GitHub. It uses a configuration file to specify the directories to watch. (Actually, each user can set up their own configuration file).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top