Sunday, January 13, 2019

BASH script to update all SVN archives

I have a base root for my SVN repositories, such as:
./svn
./svn/project1
./svn/project2
In order to update everything, I made a script that will execute from any SVN repository and update all of the unrelated repos.

#!/bin/bash
#Before anything else, set the PATH_SCRIPT variable
    pushd `dirname $0` > /dev/nullPATH_SCRIPT=`pwd -P`popd > /dev/null
    PROGNAME=${0##*/}; PROGVERSION=0.1.0 
##
## This program attempts to do a SVN update on all of the directories off an SVN_ROOT

SVN_ROOT=$(svn info | awk -F'/Root Path: (.*)/ { print $2 }' | xargs)
SVN_ROOT=$(dirname $SVN_ROOT)
echo "$SVN_ROOT"

for svndir in $SVN_ROOT/* ; do
    BRANCH=`svn info ${svndir} 2> /dev/null | grep "^URL:" | cut -d" " -f2 `
     if [ -z "${BRANCH}" ]
    then
        #echo "Error: directory ${svndir} exists and is not part of a working copy."
        echo "skipping: ${svndir}"
    else
        #echo "$svndir"
        svn update $svndir
    fi
done


No comments:

Post a Comment