Bash Script to Automate SVN

Because I am that much of a geek, I decided to create a bash script to automate my SVN adds and updates. Now, this won’t make it easier to send updates for any sort of changes that you may make (look to using a gui SVN client for that), but if you want something that will make it easier to auto update any files you may work on, so you don’t lose it, this is for you.

To use it, run the script name with the working repository directory as the first argument.

$> svn-helper.sh current_repo

It accepts three options, with any key forcing the auto update. If you want to specify a message, use “1″, if you want to pause the updating, hit “p” and “q” quits the script.

Any questions can be added at in the comments. Enjoy!!

#!/bin/bash
echo "Welcome to Duane's Super Awesome SVN BASH Script"
if [ -z $1 ]; then
        echo "First off, you need to specify a local repository. Please provide the exact path."
        read -p "Path: " repo
else
        repo=$1
fi
echo "Thanks!"
# Change the directory
cd $repo

echo "Starting auto add/commit..."
echo "Remember:"
echo "1 is for adding a message and then commit"
echo "p is for pausing the action"
echo "q is for quiting the process"
while true; do
        read -n1 -t300 -p "Action: " action
        echo
        case $action in
                1)
                read -p "Message: " message
                ;;
                p)
                read -p "Paused" pause
                ;;
                q)
                break
                ;;
        esac
        if [ -z message ]; then
                message="Auto Commit from BASH Script"
        fi
        echo "Adding ..."
        svn add * --force
        echo "Committing ..."
        svn commit -m message
        echo "Updating ..."
        svn update
        message=""
        action=""
done
Posted by Duane on January 21st, 2010 9:32 pm | Posted in Code | 1 Comment »