You are not logged in.

#1 2008-10-18 12:23:32

deltaecho
Member
From: Georgia (USA)
Registered: 2008-08-06
Posts: 185

Simple BASH script to update subversion files

This is just a simple BASH script that will update all .svn files in a specified directory.  If an update fails, it will attempt to update all the subdirectories in the failed one, so as much will be updated as possible.  Theoretically, you should be able to supply this script with only your root directory ( / ), and all the .svn files on your computer will be updated.

#! /bin/bash
#
# Contributor: Dylon Edwards <deltaecho@archlinux.us>
#
# ================================
# svnup: Updates subversion files.
# ================================

#  If the user supplies no arguments
#+ then, update the current directory
#+ else, update each of those specified
[[ $# == 0 ]] \
    && dirs=($PWD) \
    || dirs=($@)

# Update the target directories
for target in ${dirs[@]}; do

    # If the target file contains a .svn file
    if [[ -d $target/.svn ]]; then

        # Update the target
        svn up $target || {

            # If the update fails, update each of its subdirectories
            for subdir in $( ls $target ); do
                [[ -d $target/$subdir ]] &&
                    ( svnup $target/$subdir )
            done
        }
       
    # If the target file doesn't contain a .svn file
    else
        # Update each of its subdirectories
        for subdir in $( ls $target ); do
            [[ -d $target/$subdir ]] &&
                ( svnup $target/$subdir )
        done;
    fi
done


Dylon

Offline

Board footer

Powered by FluxBB