3 # implement the workflow between the various branches in flab
4 # basically keep the 2 branches generic and senslab
5 # in sync with master from upstream
7 # this is expected to be a standalone directory *not* a workdir
8 # initialized with a clone from git.f-lab.fr/sfa.git
10 COMMAND=$(basename $0)
12 DEFAULT_WORKDIR=/Users/parmentelat/git/sfa-flab-sync
13 UPSTREAMREPO=ssh://thierry@git.onelab.eu/git/sfa.git
14 FLABREPO=ssh://thierry@git.f-lab.fr/git/sfa.git
15 TOTRACK="generic senslab"
21 echo "====================" "$@"
26 echo Emergency exit -- Bailing out
30 function check_or_create_workdir () {
31 [ -d $WORKDIR ] && return
32 msg Restarting with a brand new workdir $WORKDIR
33 git clone $FLABREPO $WORKDIR
36 function merge_master_in_local_branches () {
37 # start with pulling the upstream master onto flab
39 # better safe than sorry
41 msg pulling master from onelab
42 git pull $GIT_OPTIONS $UPSTREAMREPO refs/heads/master:refs/heads/master
43 msg pushing master to flab
44 git push $GIT_OPTIONS $FLABREPO refs/heads/master:refs/heads/master
47 for branch in $TOTRACK; do
49 # update the local branch for changes from flab chaps
50 # this is expected to be fast-forward
51 msg pulling $branch from flab
52 git pull $GIT_OPTIONS $FLABREPO refs/heads/$branch:refs/heads/$branch
53 # also pull the latest master in the mix - we already have it at hand
54 # this OTOH may not be fast forward
56 msg locally merging master in $branch
57 git merge $GIT_OPTIONS master
59 msg pushing back $branch onto flab
60 git push $GIT_OPTIONS $FLABREPO refs/heads/$branch:refs/heads/$branch
65 echo "Usage: $COMMAND [options]"
67 echo "-d dir : use this dir as a workdir for merging"
68 echo " please use a *dedicated* space"
75 while getopts "d:nv" opt; do
77 d) WORKDIR=$OPTARG; shift ;;
78 n) GIT_OPTIONS="$GIT_OPTIONS -n" ;;
79 v) set -x ; GIT_OPTIONS="$GIT_OPTIONS -v" ;;
84 [ -n "$WORKDIR" ] || WORKDIR=$DEFAULT_WORKDIR
88 check_or_create_workdir
89 merge_master_in_local_branches