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
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
}
[ -n "$WORKDIR" ] || WORKDIR=$DEFAULT_WORKDIR
+ trap failure ERR INT
+
+ check_or_create_workdir
merge_master_in_local_branches
}