From c9f806bf56fdc08ba8940189510374ea7ba40a5b Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 14 Oct 2011 18:29:11 +0200 Subject: [PATCH] more reliable; hopefully it would not merge generic and senslab anymore --- scripts/flab-sync.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/flab-sync.sh b/scripts/flab-sync.sh index ad25021..c132ec9 100755 --- a/scripts/flab-sync.sh +++ b/scripts/flab-sync.sh @@ -17,10 +17,30 @@ AGAINST=master GIT_OPTIONS="" +function msg () { + echo "====================" "$@" +} + + +function failure () { + echo Emergency exit -- Bailing out + exit 1 +} + +function check_or_create_workdir () { + [ -d $WORKDIR ] && return + msg Restarting with a brand new workdir $WORKDIR + git clone $FLABREPO $WORKDIR +} + function merge_master_in_local_branches () { # start with pulling the upstream master onto flab cd $WORKDIR + # better safe than sorry + git checkout master + msg pulling master from onelab git pull $GIT_OPTIONS $UPSTREAMREPO refs/heads/master:refs/heads/master + msg pushing master to flab git push $GIT_OPTIONS $FLABREPO refs/heads/master:refs/heads/master # manage our branches @@ -28,12 +48,15 @@ function merge_master_in_local_branches () { cd $WORKDIR # update the local branch for changes from flab chaps # this is expected to be fast-forward + msg pulling $branch from flab git pull $GIT_OPTIONS $FLABREPO refs/heads/$branch:refs/heads/$branch # also pull the latest master in the mix - we already have it at hand # this OTOH may not be fast forward git checkout $branch + msg locally merging master in $branch git merge $GIT_OPTIONS master # push back + msg pushing back $branch onto flab git push $GIT_OPTIONS $FLABREPO refs/heads/$branch:refs/heads/$branch done } @@ -60,6 +83,9 @@ function main () { [ -n "$WORKDIR" ] || WORKDIR=$DEFAULT_WORKDIR + trap failure ERR INT + + check_or_create_workdir merge_master_in_local_branches } -- 2.43.0