aboutsummaryrefslogtreecommitdiffstats
path: root/admin/automerge
diff options
context:
space:
mode:
authorGlenn Morris2018-01-18 20:22:53 -0500
committerGlenn Morris2018-01-18 20:22:53 -0500
commit256bd99a8bfae91a3c91ae20166af45918d1e986 (patch)
treeec2a65c217748d0ca36ea5e0d9188d8374fb240b /admin/automerge
parent6213ce554410213d5ffd3acb09ea2ebde8402281 (diff)
downloademacs-256bd99a8bfae91a3c91ae20166af45918d1e986.tar.gz
emacs-256bd99a8bfae91a3c91ae20166af45918d1e986.zip
* admin/automerge: New script.
Diffstat (limited to 'admin/automerge')
-rwxr-xr-xadmin/automerge196
1 files changed, 196 insertions, 0 deletions
diff --git a/admin/automerge b/admin/automerge
new file mode 100755
index 00000000000..d96974ca562
--- /dev/null
+++ b/admin/automerge
@@ -0,0 +1,196 @@
1#!/bin/bash
2### automerge - merge the Emacs release branch to master
3
4## Copyright (C) 2018 Free Software Foundation, Inc.
5
6## Author: Glenn Morris <rgm@gnu.org>
7
8## This file is part of GNU Emacs.
9
10## GNU Emacs is free software: you can redistribute it and/or modify
11## it under the terms of the GNU General Public License as published by
12## the Free Software Foundation, either version 3 of the License, or
13## (at your option) any later version.
14
15## GNU Emacs is distributed in the hope that it will be useful,
16## but WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18## GNU General Public License for more details.
19
20## You should have received a copy of the GNU General Public License
21## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22
23### Commentary:
24
25## Automatically merge the Emacs release branch to master.
26## No warranty, etc.
27
28die () # write error to stderr and exit
29{
30 [ $# -gt 0 ] && echo "$PN: $@" >&2
31 exit 1
32}
33
34PN=${0##*/} # basename of script
35PD=${0%/*}
36
37[ "$PD" = "$0" ] && PD=. # if PATH includes PWD
38
39## This should be the admin directory.
40cd $PD
41cd ../
42[ -d admin ] || die "Could not locate admin directory"
43
44[ -e .git ] || die "No .git"
45
46usage ()
47{
48 cat 1>&2 <<EOF
49Usage: ${PN} [-b] [-e emacs] [-n nmin] [-p] [-t] [-- make-flags]
50Merge the Emacs release branch to master.
51Passes any non-option args to make (eg -- -j2).
52Options:
53-e: Emacs executable to use for the initial merge (default $emacs)
54-n: Minimum number of commits to try merging (default $nmin)
55-b: try to build after merging
56-t: try to check after building
57-p: if merge, build, check all succeed, push when finished (caution!)
58EOF
59 exit 1
60}
61
62
63## Defaults.
64
65emacs=emacs
66nmin=10
67build=
68test=
69push=
70quiet=
71
72while getopts ":hbe:n:pqt" option ; do
73 case $option in
74 (h) usage ;;
75
76 (b) build=1 ;;
77
78 (e) emacs=$OPTARG ;;
79
80 (n) nmin=$OPTARG ;;
81
82 (p) push=1 ;;
83
84 (q) quiet=1 ;;
85
86 (t) test=1 ;;
87
88 (\?) die "Bad option -$OPTARG" ;;
89
90 (:) die "Option -$OPTARG requires an argument" ;;
91
92 (*) die "getopts error" ;;
93 esac
94done
95shift $(( --OPTIND ))
96OPTIND=1
97
98
99## Does not work 100% because a lot of Emacs batch output comes on
100## stderr (?).
101[ "$quiet" ] && exec 1> /dev/null
102
103
104[ "$push" ] && test=1
105[ "$test" ] && build=1
106
107
108tempfile=/tmp/$PN.$$
109
110trap "rm -f $tempfile 2> /dev/null" EXIT
111
112
113[ -e Makefile ] && [ "$build" ] && {
114 echo "Cleaning..."
115 make maintainer-clean >& /dev/null
116}
117
118
119echo "Merging..."
120
121if $emacs --batch -Q -l ./admin/gitmerge.el \
122 --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \
123 >| $tempfile 2>&1; then
124 echo "merged ok"
125
126else
127 grep -qE "Nothing to merge|Number of missing commits" $tempfile && {
128 echo "Fewer than $nmin commits to merge"
129 exit 0
130 }
131
132 cat "$tempfile" 1>&2
133
134 die "merge error"
135fi
136
137
138[ "$build" ] || exit 0
139
140
141echo "Running autoreconf..."
142
143autoreconf -i -I m4 2>| $tempfile
144
145retval=$?
146
147## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
148if [ "$quiet" ]; then
149 grep -v 'installing `\.' $tempfile 1>&2
150else
151 cat "$tempfile" 1>&2
152fi
153
154[ $retval -ne 0 ] && die "autoreconf error"
155
156
157echo "Running ./configure..."
158
159## Minimize required packages.
160./configure --without-x || die "configure error"
161
162
163echo "Building..."
164
165make "$@" || die "make error"
166
167echo "Build finished ok"
168
169
170[ "$test" ] || exit 0
171
172
173echo "Testing..."
174
175make "$@" check || die "check error"
176
177echo "Tests finished ok"
178
179
180[ "$push" ] || exit 0
181
182
183## In case someone else pushed while we were working.
184echo "Checking for remote changes..."
185git fetch || die "fetch error"
186## git >= 1.8.5 has "pull --rebase=preserve"
187git rebase --preserve-merges || die "rebase error"
188
189
190echo "Pushing..."
191git push || die "push error"
192
193
194exit 0
195
196### automerge ends here