Svn hook script – export just branch checked in

hooksvn

I've set up a repository to configure my websites, the repository is /subversion/web and at the moment I have just one website controlled in /subversion/web/mywebsite

I've set up a post-commit hook script that exports the site into a web directory on the server for testing before I publish it all separately and it works fine.

What I'd like to do is set the script so that I can control a second website in the same repository but only have 'mywebsite' export when I check in a file related to that project.

I've set it up this way because I access the repository from a number of computers via http, it makes it easier to create new projects without having to create a whole new repository and configure apache to point at it and all the rest of it.

latest svn running on latest ubuntu with latest apache2

Best Answer

You can do this using the "svnlook" command.

Here's an example post-commit hook:

#!/bin/sh
REPOS="$1"
REV="$2"
/usr/bin/svnlook dirs-changed -r "$REV" "$REPOS" | egrep -q '^mywebsite'
if [ $? -eq 0 ] ; then
    # publish site code
fi

You may need to run svnlook manually a few times to become familiar with the output and see how to set the match pattern for the grep.

Related Topic