Subversion :: post-commit auto-update
By cyril on Friday 22 March 2013, 09:19 - VCS - Permalink
Simple
bash script to maintain working copy on post-commit
post-commit script :
#!/bin/bash REPOS="$1" REV="$2" /repositories/svn-replicate/scripts/wc-auto-update.sh "$REPOS" "$REV" /repositories/cfengine/ || logger -t wc-auto-update FAILED exit 0
wc-auto-update.sh script (in a wc auto-updated):
#!/bin/bash REPOS="$1" REV="$2" LOCAL_WC="$3" user=`/usr/bin/whoami` function logme () { /usr/bin/logger -t "wc-a-u:repos=[${REPOS}],user=[${user}],rev=[${REV}],dir_changed=[${mydir}]" "$@" } if ! [ -d "${LOCAL_WC}" ] ; then logme "The working copy [${LOCAL_WC}] is not a directory" exit 1 fi if ! /usr/bin/svnlook youngest "${REPOS}" >/dev/null 2>&1 ; then logme "svn repository [${REPOS}] do not exists" exit 1 fi logme "beginning" # behaviours case ${LOCAL_WC} in /repositories/cfengine*) for mydir in $(/usr/bin/svnlook dirs-changed "${REPOS}" -r "${REV}"); do if [ ${mydir:0:6} = "trunk/" ] ; then /usr/bin/sudo -H -u cfengine /usr/bin/svn update "${LOCAL_WC}/${mydir}" 2>&1 | logme else echo "post-commit auto-update not contain trunk file for cfengine repository" | logme fi done ;; *) # branches/prod replication for mydir in $(/usr/bin/svnlook dirs-changed "${REPOS}" -r "${REV}"); do if [ ${mydir:0:9} = "branches/" ] ; then /usr/bin/sudo -H -u cfengine /usr/bin/svn update "${LOCAL_WC}/${mydir}" 2>&1 | logme fi done ;; esac logme "ending" # RTFM http://tldp.org/LDP/abs/html/string-manipulation.html exit 0