summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-03-11 16:06:32 +0200
committerArtur Signell <artur@vaadin.com>2013-03-12 12:56:53 +0200
commit1853dea1b9277f2d5a8911bd2d20277158e221b7 (patch)
tree73b3f914b6c5bda9017370ef7b374556b538d0c5
parent06748244ae0ebd8f43742a2c0b3349794b169b45 (diff)
downloadvaadin-framework-1853dea1b9277f2d5a8911bd2d20277158e221b7.tar.gz
vaadin-framework-1853dea1b9277f2d5a8911bd2d20277158e221b7.zip
Script for merging changes from a bugfix branch into master (#11299)
* Supports "Merge: no" for changesets which should be skipped, e.g. release notes updates. * Supports "Merge: manual" which will causes the merge to stop, requiring somebody to manually merge to change before continuing Change-Id: If5d1291ec77f4c1e31b3afb8420a45ecceedfa15
-rwxr-xr-xscripts/automerge7.sh104
1 files changed, 104 insertions, 0 deletions
diff --git a/scripts/automerge7.sh b/scripts/automerge7.sh
new file mode 100755
index 0000000000..8f8ed9a785
--- /dev/null
+++ b/scripts/automerge7.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+FROM=origin/7.0
+TO=master
+PUSH="origin HEAD:refs/for/master"
+
+show() {
+ sCommit=$1
+ if [ "$sCommit" == "" ]
+ then
+ echo "show() missing commit id"
+ exit 1
+ fi
+ git show -s $sCommit
+}
+merge() {
+ mCommit=$1
+ if [ "$mCommit" == "" ]
+ then
+ echo "merge() missing commit id"
+ exit 1
+ fi
+
+# echo "merge($mCommit)"
+
+ git merge $mCommit $2
+ if [ "$?" != "0" ]
+ then
+ echo "Merge failed for commit $mCommit"
+ echo "Manual merge is needed"
+ exit 2
+ fi
+ # Add a change id using git hook
+ git commit --amend --no-edit
+
+}
+
+pushMerged() {
+# echo "pushMerged()"
+ git push $PUSH
+ if [ "$?" != "0" ]
+ then
+ echo "Push failed!"
+ exit 2
+ fi
+}
+
+maybe_commit_and_push() {
+# echo "maybe_commit_and_push()"
+ cpCommit=$1
+ if [ "$cpCommit" == "" ]
+ then
+ # Nothing to merge currently
+ return
+ fi
+# echo "maybe_commit_and_push: Merging $cpCommit"
+ merge $cpCommit
+ pushMerged
+}
+
+git checkout $TO
+git pull --rebase
+
+pending=`git log $TO..$FROM --reverse|grep "^commit "|sed "s/commit //"`
+
+pendingCommit=
+for commit in $pending
+do
+ echo "Checking $commit..."
+ mergeDirective=`git log -n 1 --format=%B $commit|grep "^Merge:"|sed "s/Merge: //"`
+ if [ "$mergeDirective" == "" ]
+ then
+ pendingCommit=$commit
+ elif [ "$mergeDirective" == "no" ]
+ then
+ maybe_commit_and_push $pendingCommit
+ pendingCommit=
+ echo
+ echo "Doing a no-op merge for $commit because of Merge: no"
+ # Do a no-op merge
+ git merge $commit -s ours
+ pushMerged
+ elif [ "$mergeDirective" == "manual" ]
+ then
+ maybe_commit_and_push $pendingCommit
+ pendingCommit=
+ echo
+ echo "Stopping merge at $commit (merge: manual)"
+ echo "The following commit must be manually merged."
+ show $commit
+ exit 3
+ else
+ maybe_commit_and_push $pendingCommit
+ pendingCommit=
+ echo
+ echo "Commit $commit contains an unknown merge directive, Merge: $mergeDirective"
+ echo "Stopping merge."
+ show $commit
+ exit 3
+ fi
+done
+
+# Push any pending merges
+maybe_commit_and_push $pendingCommit