If you don’t know, subversion allows you to create “hooks”, actions that are executed when certain events occur in your subversion repository. Some of the events you can use as triggers for your hooks are commits, locks, unlocks, and revision properties changes. You can create pre- and post-hooks, which just means they run before or after the event occurs.
Some examples of how these are used: sending an email to the dev team whenever a commit occurs, kicking off a deployment after a commit, or running a bunch of tests.
I needed some of these hooks for one of my projects, but I couldn’t figure out how to do it at first. Google didn’t help much - most of the examples were really old and looked like really bad ideas. Eventually, I was able to figure it out on my own, but I thought it would be a good idea to post it.
Anyway, it’s pretty easy to set these up with Dreamhost, in spite of what the Google search results will tell you.
The problem with Dreamhost’s subversion install is that all the files are owned by the dhapache user and therefore you can’t make the .tmpl files executable (the .tmpl files are sample hooks provided with the svn install). Normally, you would edit the files you want to use, then use the mv command in ssh to remove the .tmpl files, which is what makes subversion start acting on them. Unfortunately, doing it this way leaves your “hook” with no permission to execute, and you can’t change it.
So, the easiest thing to do is to first copy the hook template you want to use to a new file with no extension (post-commit.tmpl copied to post-commit, for example) and edit it as you like. Then chmod it to 755 and it will work.
That’s all it took. Now, if I exposed some security flaw hopefully one of my readers will know and tell me what a moron I am. I’ll appreciate that.
If you enjoyed this post, make sure you subscribe to my RSS feed!




0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment