Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /data/sites/web/remonpelnl/www/wp-content/themes/remonpel_nl__child__twentyfourteen/functions.php on line 32
Handy Shell Scripts – part IV – svnswitchto.sh – Remons TechNotes

Handy Shell Scripts – part IV – svnswitchto.sh


Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /data/sites/web/remonpelnl/www/wp-content/plugins/rmp_bitly/rmp_bitly.php on line 20

So, you’re developing with SVN and you want to use branches? Creating a branch is easy, but switching between them by manually typing those URLs can be annoying. Use this script :)

SVN Branch Switcher (download file)#!/bin/sh

[ ! -d ".svn" ] && echo Use only inside the main project directory under SVN control && exit
S=` svn info | grep URL: | cut -d " " -f 2 `
echo Currently on $S
#echo $S
#exit;
BSE=` echo $S | sed 's/\/trunk/ /' | sed 's/\/branches/ /' | sed 's/\/tags/ /' | cut -d " " -f 1 `
BASEBRANCHES=$BSE/branches
TARGET=$BASEBRANCHES/$1

[ "$1" == "" ] && TARGET=$BSE/trunk
[ "$TARGET" != "$BSE/trunk" ] && [ "` svn ls $BASEBRANCHES | egrep \"^$1/$\" | wc -l | egrep -o \"[0-9]+\"`" == "0" ] && echo Branch $1 does not exist && exit;

echo Switching to $TARGET

[ "$TARGET" == "$S" ] && echo Nothing to do, already there && exit;

svn switch $TARGET

use it with a branchname as parameter and it will switch to the branch, without a parameter switches back to the trunk.

Enjoy!

Author: Remon Pel

WebDeveloper though not WebDesigner

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Confidental Infomation
stop spam mail