Background
I'm trying to implement a number of commit hooks for Subversion. I have done a lot of research to try and get a simple test hook to work, however I have had no luck.
For reference I have looked through, followed and then tried to combine methods from the following links:
1. Subversion manual for directory configuration
2. Tortoisevn manual for server side hook scripts
3. An explanation on server side hooks that contains a link to the Subversion manual
4. The wordaligned tutorial for pre-commit hooks
5. A serverfault answer for problems with commit-hooks
There are also a number of other sites that I have referenced and used, but I still cannot get commit hooks to work.
My Environment
My machine is running RHEL6 (Cent OS).
The subversion is located on a remote machine that I cannot access directly without permission from my supervisor.
The remote machine is running Subversion 1.6.
This is the current structure for my repository:
test-for-svn-hooks
|-branches
|-hooks
| +-pre-commit
|-tags
+-trunk
The file pre-commit temporarily has it permissions set to 777
. All directories have their permissions set to 775
.
This is the sample script that I created to test the commit hook:
#!/usr/bin/env bash
echo "THOU SHALL NOT PASS" 1>&2
exit 1
I have checked and tested about all that I can to make sure that my pre-commit hook is working appropriately. I don't know what else I need to check to make sure that it works. I'm able to commit whatever I like, and I get no messages output to my screen.
Questions
1. Is there anything that I have missed or overlooked in implementing hooks?
2. If I implement a hook in this fashion do I have to worry about implementing the same hook again in Tortoisesvn?
Any feedback and/or suggestions are greatly appreciated.
Best Answer
Don't use permission 777. Sometimes this can actually be counterproductive. Some tools might not work with such suspicious permissions. In your case this is unlikely to be the problem, because it works for me with this setting. But just don't do it. Change it to 755.
Another sanity check to do is running the hook script directly on the server:
When you're script has more meaningful content, then you should test with proper parameters too, for example:
Next, test it using a checkout on the server itself, for example:
Based on what you've written in your post, these steps should work. I don't know the details of the conditions under which your tests are failing. If you can reach to this point, then perhaps you will see the reason for your failed tests.
No. Hooks are defined on the server side. No need to do anything at the client side. All clients will be subject to the rules your define in the pre-commit hook.