summaryrefslogtreecommitdiff
path: root/admin/automerge
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2018-01-30 21:43:28 -0500
committerGlenn Morris <rgm@gnu.org>2018-01-30 21:43:28 -0500
commit843f3d4f34c2f54fac19d97c32399671f98ccc51 (patch)
treeaa000aeac8e88a7d92b281735d3eed5f1ee79258 /admin/automerge
parent2b0bcbbaa64f95c14deed89fdf279d8be48ee352 (diff)
downloademacs-843f3d4f34c2f54fac19d97c32399671f98ccc51.tar.gz
automerge: handle upstream changes during operation
* admin/automerge (merge): New function, split from pre-existing code. (main): If upstream changed during building and testing, reset local and try merging again.
Diffstat (limited to 'admin/automerge')
-rwxr-xr-xadmin/automerge75
1 files changed, 53 insertions, 22 deletions
diff --git a/admin/automerge b/admin/automerge
index 54ac88db4ff..94b41d2cdca 100755
--- a/admin/automerge
+++ b/admin/automerge
@@ -1,5 +1,5 @@
#!/bin/bash
-### automerge - merge the Emacs release branch to master
+### automerge - automatically merge the Emacs release branch to master
## Copyright (C) 2018 Free Software Foundation, Inc.
@@ -23,7 +23,12 @@
### Commentary:
## Automatically merge the Emacs release branch to master.
-## No warranty, etc.
+## If the merge succeeds, optionally build and test the results,
+## and then push it.
+## Intended usage:
+## Have a dedicated git directory just for this.
+## Have a cron job that does a hard reset (to clean up after any
+## previous failures), then a git pull, then calls this script with -p.
die () # write error to stderr and exit
{
@@ -116,23 +121,35 @@ trap "rm -f $tempfile 2> /dev/null" EXIT
}
-echo "Merging..."
+rev=$(git rev-parse HEAD)
-if $emacs --batch -Q -l ./admin/gitmerge.el \
- --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \
- >| $tempfile 2>&1; then
- echo "merged ok"
+[ $(git rev-parse @{u}) = $rev ] || die "Local state does not match origin"
-else
- grep -qE "Nothing to merge|Number of missing commits" $tempfile && {
- echo "Fewer than $nmin commits to merge"
- exit 0
- }
- cat "$tempfile" 1>&2
+merge ()
+{
+ echo "Merging..."
- die "merge error"
-fi
+ if $emacs --batch -Q -l ./admin/gitmerge.el \
+ --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \
+ >| $tempfile 2>&1; then
+ echo "merged ok"
+ return 0
+
+ else
+ grep -qE "Nothing to merge|Number of missing commits" $tempfile && {
+ echo "Fewer than $nmin commits to merge"
+ exit 0
+ }
+
+ cat "$tempfile" 1>&2
+
+ die "merge error"
+ fi
+}
+
+
+merge
[ "$build" ] || exit 0
@@ -181,14 +198,28 @@ echo "Tests finished ok"
## In case someone else pushed while we were working.
-#echo "Checking for remote changes..."
-#git fetch || die "fetch error"
-## NB If there were remote changes, this would rewrite the release
-## branch commits, which is not what we want.
-## Ref eg http://lists.gnu.org/r/emacs-devel/2014-12/msg01435.html
-## git >= 1.8.5 has "pull --rebase=preserve"
-#git rebase --preserve-merges || die "rebase error"
+echo "Checking for remote changes..."
+git fetch || die "fetch error"
+
+[ $(git rev-parse @{u}) = $rev ] || {
+
+ echo "Upstream has changed"
+ ## Rebasing would be incorrect, since it would rewrite the
+ ## (already published) release branch commits.
+ ## Ref eg http://lists.gnu.org/r/emacs-devel/2014-12/msg01435.html
+ ## Instead, we throw away what we just did, and do the merge again.
+ echo "Resetting..."
+ git reset --hard $rev
+
+ echo "Pulling..."
+ git pull --ff-only || die "pull error"
+
+ merge
+
+ ## If the merge finished ok again, we don't bother doing a second
+ ## build and test.
+}
echo "Pushing..."
git push || die "push error"