From: Thierry Parmentelat Date: Wed, 12 Oct 2011 13:41:06 +0000 (+0200) Subject: first draft for a merging script for our branches in sfa X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e1962aba9a8c942d4d36325a6b8b377df0c7384d;p=infrastructure.git first draft for a merging script for our branches in sfa --- diff --git a/scripts/flab-sync.sh b/scripts/flab-sync.sh new file mode 100755 index 0000000..ad25021 --- /dev/null +++ b/scripts/flab-sync.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# implement the workflow between the various branches in flab +# basically keep the 2 branches generic and senslab +# in sync with master from upstream + +# this is expected to be a standalone directory *not* a workdir +# initialized with a clone from git.f-lab.fr/sfa.git + +COMMAND=$(basename $0) + +DEFAULT_WORKDIR=/Users/parmentelat/git/sfa-flab-sync +UPSTREAMREPO=ssh://thierry@git.onelab.eu/git/sfa.git +FLABREPO=ssh://thierry@git.f-lab.fr/git/sfa.git +TOTRACK="generic senslab" +AGAINST=master + +GIT_OPTIONS="" + +function merge_master_in_local_branches () { + # start with pulling the upstream master onto flab + cd $WORKDIR + git pull $GIT_OPTIONS $UPSTREAMREPO refs/heads/master:refs/heads/master + git push $GIT_OPTIONS $FLABREPO refs/heads/master:refs/heads/master + + # manage our branches + for branch in $TOTRACK; do + cd $WORKDIR + # update the local branch for changes from flab chaps + # this is expected to be fast-forward + 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 + git merge $GIT_OPTIONS master + # push back + git push $GIT_OPTIONS $FLABREPO refs/heads/$branch:refs/heads/$branch + done +} + +function usage () { + echo "Usage: $COMMAND [options]" + echo "Options" + echo "-d dir : use this dir as a workdir for merging" + echo " please use a *dedicated* space" + echo " -n : dry-run" + echo " -v : verbose" + exit 1 +} + +function main () { + while getopts "d:nv" opt; do + case $opt in + d) WORKDIR=$OPTARG; shift ;; + n) GIT_OPTIONS="$GIT_OPTIONS -n" ;; + v) set -x ; GIT_OPTIONS="$GIT_OPTIONS -v" ;; + *) usage;; + esac + done + + [ -n "$WORKDIR" ] || WORKDIR=$DEFAULT_WORKDIR + + merge_master_in_local_branches + +} + +### +main "$@" + +