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

╄→尐↘猪︶ㄣ 提交于 2019-12-24 17:53:17

问题


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.


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/11521100/post-commit-hook-that-performs-an-action-only-if-commit-affects-the-specific-pat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!