From 8f9505e1425c00dda3e841f89c0d3659b58557af Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 11 Apr 2013 02:58:10 -0400 Subject: [PATCH] Add tools/scripts/merge-forward --- tools/scripts/merge-forward | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 tools/scripts/merge-forward diff --git a/tools/scripts/merge-forward b/tools/scripts/merge-forward new file mode 100755 index 0000000000..f7939fd79d --- /dev/null +++ b/tools/scripts/merge-forward @@ -0,0 +1,52 @@ +#!/bin/bash +set -e + +RELPATH="$1" +REMOTE="$2" +MAINTBRANCH="$3" +DEVBRANCH="$4" +TMPBRANCH=$MAINTBRANCH-$DEVBRANCH-$(date "+%Y-%m-%d-%H-%M-%S") + +if [ -z "$RELPATH" -o -z "$REMOTE" -o -z "$MAINTBRANCH" -o -z "$DEVBRANCH" ] ; then + PROG=$(basename $0) + echo "Merge any changes from the maintenance-branch into the development-branch." + echo "If there are no conflicts, then push the changes." + echo "" + echo "Usage: $PROG " + echo "" + echo "Example: $PROG drupal upstream 7.x-4.3 7.x-master" + exit 1 +fi + +pushd "$RELPATH" >> /dev/null + TMPFILE=$(mktemp) + + set -x + git fetch $REMOTE + git checkout -b $TMPBRANCH $REMOTE/$DEVBRANCH + git merge $REMOTE/$MAINTBRANCH | tee $TMPFILE + set +x + + if grep -q CONFLICT "$TMPFILE" ; then + echo "" + echo "==> Conflicted merge. Please resolve conflicts and then push with:" + echo "" + echo "git push $REMOTE $TMPBRANCH:$DEVBRANCH" + elif grep -q "Already up-to-date." "$TMPFILE" ; then + echo "" + echo "==> No update needed" + echo "" + else + echo "" + echo "==> Clean merge; proceeding with push" + echo "" + set -x + git push $REMOTE $TMPBRANCH:$DEVBRANCH + git fetch $REMOTE + git checkout $REMOTE/$DEVBRANCH + git branch -d $TMPBRANCH + set +x + fi + + /bin/rm -f "$TMPFILE" +popd >> /dev/null -- 2.25.1