Search code examples
svnhookpost-commit

SVN post commit hook not working?


Navigate to TortoiseSVN on mine local box, open settings and 'Hook Scripts'. Click 'Add...' and entered below values

Hook Type post_commit_hook

Working Copy Path https:\svn.internal.net\svn\Release_Customer

Command Line to Execute C:\postCommitHook.bat

postCommitHook.bat file content is

"C:\Program Files\TortoiseSVN\bin\svnlook.exe" log -t %2 %1 | FindStr [a-zA-Z0-9]
IF %ERRORLEVEL% EQU 0 GOTO OK
echo "Commit Comments are Required" >&2
exit 1
:OK
exit 0

But when I commit from my local box code(pointing To https:\svn.internal.net\svn\Release_Customer) without any comment, i am still able to commit. Why my postCommitHook.bat is restricting it ?

Basically i an trying add the restriction to svn repo(https:\\svn.internal.net\svn\Release_Customer) where as batch script is lying on local box. Is it fine ?


Solution

  • You have two issues:

    1. If you want to block a commit from happening, it must happen in the pre-commit hook script. The post-commit hook executes after a successful commit, which is not helpful for your use case.
    2. The hook you've configured is local only to your computer, and for commits performed via TortoiseSVN. To install a hook script in the repository, you need an appropriate level of access to the filesystem on your SVN server itself, to place it in the hooks directory of the repository database itself. More info in the manual