Writing an SVN hook that updates copy of committed code

Posted by Jordan Reiter on Server Fault See other posts from Server Fault or by Jordan Reiter
Published on 2012-08-27T17:56:09Z Indexed on 2012/08/28 3:40 UTC
Read the original article Hit count: 575

Filed under:
|
|

I have a SVN repository with a lot of sub-projects stored in it. Right now in my post-commit I just loop through all possible folders on the machine and run svn update on each:

REPOS="$1"
REV="$2"
DIRS=("/path/to/local/copy/firstproject" "/path/to/local/copy/anotherproject" ... "/path/to/local/copy/spam")
LOGNAME=`/usr/bin/whoami`

for DIR in ${DIRS[@]}
do
    cd $DIR
    sudo /usr/bin/svn update --accept=postpone 2>&1 | logger
    logger "$LOGNAME Updated $DIR to revision $REV (from $REPOS) "
done

The problem is that this is slow and redundant when I'm just committing the subfolder of one of the projects. I'm wondering if there's a better way of identifying which of the DIRS I should use and only update that one.

Is there some way to do this? As far as I can tell there's no way to determine which part of a repo was committed and thus which directory needs to be updated.

Is the only alternative to create a separate repository for each project? (Probably should have done that from the start, if so...)

© Server Fault or respective owner

Related posts about bash

Related posts about svn