简体   繁体   中英

Post-commit hook that performs an action only if commit affects the specific path

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

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

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 %*

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM