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...)
svnlook dirs-changed
is what you're looking for:Try something like this:
Here's the script I ended up using, based on quanta's help:
Note that the one big thing I had to add was the
declare -A PROJECTS
line. For some reason the associative array/hash wouldn't work until I did this.