From 56595590f155b5bbcc9140aeb92c4e1e79c9e061 Mon Sep 17 00:00:00 2001 From: Michael Iedema Date: Mon, 24 Mar 2014 17:23:46 +0100 Subject: [PATCH] - split clone and pull operations - clone now also creates local branches tracking origin - basic status script added --- clone.sh | 44 +++++++++++++++++++++++++++++++ clonepull.sh => pull.sh | 23 +++++----------- rename.sh | 1 + state.sh | 58 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 16 deletions(-) create mode 100755 clone.sh rename clonepull.sh => pull.sh (78%) create mode 100755 state.sh diff --git a/clone.sh b/clone.sh new file mode 100755 index 0000000..1b9c49e --- /dev/null +++ b/clone.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Copyright 2014 Range Networks, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# See the COPYING file in the main directory for details. +# + +sayAndDo () { + echo $@ + eval $@ + if [ $? -ne 0 ]; then + echo "# ERROR: command failed!" + exit 1 + fi +} + +for component in a53 CommonLibs openbts RRLP smqueue sqlite3 subscriberRegistry +do + if [ ! -d $component ]; then + echo "# cloning $component" + sayAndDo git clone --recursive git@github.com:RangeNetworks/$component.git + cd $component + for remote in `git branch -r | grep -v master ` + do + sayAndDo git checkout --track $remote + done + sayAndDo git checkout master + sayAndDo git submodule foreach 'git checkout master' + cd .. + echo + fi +done diff --git a/clonepull.sh b/pull.sh similarity index 78% rename from clonepull.sh rename to pull.sh index a731296..7d64b56 100755 --- a/clonepull.sh +++ b/pull.sh @@ -26,25 +26,16 @@ sayAndDo () { fi } -cloneOrPull () { - if [ ! -d $@ ]; then - echo "# cloning $@" - sayAndDo git clone --recursive git@github.com:RangeNetworks/$@.git - sayAndDo cd $@ - sayAndDo git submodule foreach 'git checkout master' - sayAndDo cd .. - else - echo "# pulling $@" - sayAndDo cd $@ +for component in a53 CommonLibs openbts RRLP smqueue sqlite3 subscriberRegistry +do + if [ -d $component ]; then + echo "# pulling $component" + cd $component sayAndDo git pull sayAndDo git submodule update --remote sayAndDo git submodule foreach 'git checkout master' sayAndDo git submodule foreach 'git pull' - sayAndDo cd .. + cd .. + echo fi -} - -for component in a53 CommonLibs openbts RRLP smqueue sqlite3 subscriberRegistry -do - cloneOrPull $component done diff --git a/rename.sh b/rename.sh index 5579e65..c224b21 100755 --- a/rename.sh +++ b/rename.sh @@ -93,6 +93,7 @@ if [ $ANSWER == "yes" ]; then echo "# - pushing to origin..." sayAndDo git push origin --delete $OLDNAME sayAndDo git push origin $NEWNAME + sayAndDo git branch -D $NEWNAME echo "# - restoring workspace branch..." sayAndDo git checkout $BOOKMARK fi diff --git a/state.sh b/state.sh new file mode 100755 index 0000000..23415ad --- /dev/null +++ b/state.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Copyright 2014 Range Networks, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# See the COPYING file in the main directory for details. +# + +sayAndDo () { + echo $@ + eval $@ + if [ $? -ne 0 ]; then + echo "# ERROR: command failed!" + exit 1 + fi +} + +usage () { + echo "# usage: ./state.sh (branches, tags)" + exit 1 +} + +if [ -z "$1" ]; then + type=status +elif [ $1 == "branches" ]; then + type=branch +elif [ $1 == "tags" ]; then + type=tag +else + usage +fi + +for component in a53 CommonLibs openbts RRLP smqueue sqlite3 subscriberRegistry +do + if [ -d $component ]; then + echo "########################################################################" + echo "# $component" + cd $component + if [ $type == "status" ]; then + git status + else + git $type + fi + cd .. + echo + fi +done \ No newline at end of file