diff options
| author | Glenn Morris | 2018-01-30 21:43:28 -0500 |
|---|---|---|
| committer | Glenn Morris | 2018-01-30 21:43:28 -0500 |
| commit | 843f3d4f34c2f54fac19d97c32399671f98ccc51 (patch) | |
| tree | aa000aeac8e88a7d92b281735d3eed5f1ee79258 /admin/automerge | |
| parent | 2b0bcbbaa64f95c14deed89fdf279d8be48ee352 (diff) | |
| download | emacs-843f3d4f34c2f54fac19d97c32399671f98ccc51.tar.gz emacs-843f3d4f34c2f54fac19d97c32399671f98ccc51.zip | |
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-x | admin/automerge | 75 |
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 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | ### automerge - merge the Emacs release branch to master | 2 | ### automerge - automatically merge the Emacs release branch to master |
| 3 | 3 | ||
| 4 | ## Copyright (C) 2018 Free Software Foundation, Inc. | 4 | ## Copyright (C) 2018 Free Software Foundation, Inc. |
| 5 | 5 | ||
| @@ -23,7 +23,12 @@ | |||
| 23 | ### Commentary: | 23 | ### Commentary: |
| 24 | 24 | ||
| 25 | ## Automatically merge the Emacs release branch to master. | 25 | ## Automatically merge the Emacs release branch to master. |
| 26 | ## No warranty, etc. | 26 | ## If the merge succeeds, optionally build and test the results, |
| 27 | ## and then push it. | ||
| 28 | ## Intended usage: | ||
| 29 | ## Have a dedicated git directory just for this. | ||
| 30 | ## Have a cron job that does a hard reset (to clean up after any | ||
| 31 | ## previous failures), then a git pull, then calls this script with -p. | ||
| 27 | 32 | ||
| 28 | die () # write error to stderr and exit | 33 | die () # write error to stderr and exit |
| 29 | { | 34 | { |
| @@ -116,23 +121,35 @@ trap "rm -f $tempfile 2> /dev/null" EXIT | |||
| 116 | } | 121 | } |
| 117 | 122 | ||
| 118 | 123 | ||
| 119 | echo "Merging..." | 124 | rev=$(git rev-parse HEAD) |
| 120 | 125 | ||
| 121 | if $emacs --batch -Q -l ./admin/gitmerge.el \ | 126 | [ $(git rev-parse @{u}) = $rev ] || die "Local state does not match origin" |
| 122 | --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \ | ||
| 123 | >| $tempfile 2>&1; then | ||
| 124 | echo "merged ok" | ||
| 125 | 127 | ||
| 126 | else | ||
| 127 | grep -qE "Nothing to merge|Number of missing commits" $tempfile && { | ||
| 128 | echo "Fewer than $nmin commits to merge" | ||
| 129 | exit 0 | ||
| 130 | } | ||
| 131 | 128 | ||
| 132 | cat "$tempfile" 1>&2 | 129 | merge () |
| 130 | { | ||
| 131 | echo "Merging..." | ||
| 133 | 132 | ||
| 134 | die "merge error" | 133 | if $emacs --batch -Q -l ./admin/gitmerge.el \ |
| 135 | fi | 134 | --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \ |
| 135 | >| $tempfile 2>&1; then | ||
| 136 | echo "merged ok" | ||
| 137 | return 0 | ||
| 138 | |||
| 139 | else | ||
| 140 | grep -qE "Nothing to merge|Number of missing commits" $tempfile && { | ||
| 141 | echo "Fewer than $nmin commits to merge" | ||
| 142 | exit 0 | ||
| 143 | } | ||
| 144 | |||
| 145 | cat "$tempfile" 1>&2 | ||
| 146 | |||
| 147 | die "merge error" | ||
| 148 | fi | ||
| 149 | } | ||
| 150 | |||
| 151 | |||
| 152 | merge | ||
| 136 | 153 | ||
| 137 | 154 | ||
| 138 | [ "$build" ] || exit 0 | 155 | [ "$build" ] || exit 0 |
| @@ -181,14 +198,28 @@ echo "Tests finished ok" | |||
| 181 | 198 | ||
| 182 | 199 | ||
| 183 | ## In case someone else pushed while we were working. | 200 | ## In case someone else pushed while we were working. |
| 184 | #echo "Checking for remote changes..." | 201 | echo "Checking for remote changes..." |
| 185 | #git fetch || die "fetch error" | 202 | git fetch || die "fetch error" |
| 186 | ## NB If there were remote changes, this would rewrite the release | 203 | |
| 187 | ## branch commits, which is not what we want. | 204 | [ $(git rev-parse @{u}) = $rev ] || { |
| 188 | ## Ref eg http://lists.gnu.org/r/emacs-devel/2014-12/msg01435.html | 205 | |
| 189 | ## git >= 1.8.5 has "pull --rebase=preserve" | 206 | echo "Upstream has changed" |
| 190 | #git rebase --preserve-merges || die "rebase error" | ||
| 191 | 207 | ||
| 208 | ## Rebasing would be incorrect, since it would rewrite the | ||
| 209 | ## (already published) release branch commits. | ||
| 210 | ## Ref eg http://lists.gnu.org/r/emacs-devel/2014-12/msg01435.html | ||
| 211 | ## Instead, we throw away what we just did, and do the merge again. | ||
| 212 | echo "Resetting..." | ||
| 213 | git reset --hard $rev | ||
| 214 | |||
| 215 | echo "Pulling..." | ||
| 216 | git pull --ff-only || die "pull error" | ||
| 217 | |||
| 218 | merge | ||
| 219 | |||
| 220 | ## If the merge finished ok again, we don't bother doing a second | ||
| 221 | ## build and test. | ||
| 222 | } | ||
| 192 | 223 | ||
| 193 | echo "Pushing..." | 224 | echo "Pushing..." |
| 194 | git push || die "push error" | 225 | git push || die "push error" |