* admin/automerge: New script.
This commit is contained in:
parent
6213ce5544
commit
256bd99a8b
1 changed files with 196 additions and 0 deletions
196
admin/automerge
Executable file
196
admin/automerge
Executable file
|
@ -0,0 +1,196 @@
|
|||
#!/bin/bash
|
||||
### automerge - merge the Emacs release branch to master
|
||||
|
||||
## Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
|
||||
## This file is part of GNU Emacs.
|
||||
|
||||
## GNU Emacs is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
|
||||
## GNU Emacs is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
## Automatically merge the Emacs release branch to master.
|
||||
## No warranty, etc.
|
||||
|
||||
die () # write error to stderr and exit
|
||||
{
|
||||
[ $# -gt 0 ] && echo "$PN: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
PN=${0##*/} # basename of script
|
||||
PD=${0%/*}
|
||||
|
||||
[ "$PD" = "$0" ] && PD=. # if PATH includes PWD
|
||||
|
||||
## This should be the admin directory.
|
||||
cd $PD
|
||||
cd ../
|
||||
[ -d admin ] || die "Could not locate admin directory"
|
||||
|
||||
[ -e .git ] || die "No .git"
|
||||
|
||||
usage ()
|
||||
{
|
||||
cat 1>&2 <<EOF
|
||||
Usage: ${PN} [-b] [-e emacs] [-n nmin] [-p] [-t] [-- make-flags]
|
||||
Merge the Emacs release branch to master.
|
||||
Passes any non-option args to make (eg -- -j2).
|
||||
Options:
|
||||
-e: Emacs executable to use for the initial merge (default $emacs)
|
||||
-n: Minimum number of commits to try merging (default $nmin)
|
||||
-b: try to build after merging
|
||||
-t: try to check after building
|
||||
-p: if merge, build, check all succeed, push when finished (caution!)
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
## Defaults.
|
||||
|
||||
emacs=emacs
|
||||
nmin=10
|
||||
build=
|
||||
test=
|
||||
push=
|
||||
quiet=
|
||||
|
||||
while getopts ":hbe:n:pqt" option ; do
|
||||
case $option in
|
||||
(h) usage ;;
|
||||
|
||||
(b) build=1 ;;
|
||||
|
||||
(e) emacs=$OPTARG ;;
|
||||
|
||||
(n) nmin=$OPTARG ;;
|
||||
|
||||
(p) push=1 ;;
|
||||
|
||||
(q) quiet=1 ;;
|
||||
|
||||
(t) test=1 ;;
|
||||
|
||||
(\?) die "Bad option -$OPTARG" ;;
|
||||
|
||||
(:) die "Option -$OPTARG requires an argument" ;;
|
||||
|
||||
(*) die "getopts error" ;;
|
||||
esac
|
||||
done
|
||||
shift $(( --OPTIND ))
|
||||
OPTIND=1
|
||||
|
||||
|
||||
## Does not work 100% because a lot of Emacs batch output comes on
|
||||
## stderr (?).
|
||||
[ "$quiet" ] && exec 1> /dev/null
|
||||
|
||||
|
||||
[ "$push" ] && test=1
|
||||
[ "$test" ] && build=1
|
||||
|
||||
|
||||
tempfile=/tmp/$PN.$$
|
||||
|
||||
trap "rm -f $tempfile 2> /dev/null" EXIT
|
||||
|
||||
|
||||
[ -e Makefile ] && [ "$build" ] && {
|
||||
echo "Cleaning..."
|
||||
make maintainer-clean >& /dev/null
|
||||
}
|
||||
|
||||
|
||||
echo "Merging..."
|
||||
|
||||
if $emacs --batch -Q -l ./admin/gitmerge.el \
|
||||
--eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \
|
||||
>| $tempfile 2>&1; then
|
||||
echo "merged ok"
|
||||
|
||||
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
|
||||
|
||||
|
||||
[ "$build" ] || exit 0
|
||||
|
||||
|
||||
echo "Running autoreconf..."
|
||||
|
||||
autoreconf -i -I m4 2>| $tempfile
|
||||
|
||||
retval=$?
|
||||
|
||||
## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
|
||||
if [ "$quiet" ]; then
|
||||
grep -v 'installing `\.' $tempfile 1>&2
|
||||
else
|
||||
cat "$tempfile" 1>&2
|
||||
fi
|
||||
|
||||
[ $retval -ne 0 ] && die "autoreconf error"
|
||||
|
||||
|
||||
echo "Running ./configure..."
|
||||
|
||||
## Minimize required packages.
|
||||
./configure --without-x || die "configure error"
|
||||
|
||||
|
||||
echo "Building..."
|
||||
|
||||
make "$@" || die "make error"
|
||||
|
||||
echo "Build finished ok"
|
||||
|
||||
|
||||
[ "$test" ] || exit 0
|
||||
|
||||
|
||||
echo "Testing..."
|
||||
|
||||
make "$@" check || die "check error"
|
||||
|
||||
echo "Tests finished ok"
|
||||
|
||||
|
||||
[ "$push" ] || exit 0
|
||||
|
||||
|
||||
## In case someone else pushed while we were working.
|
||||
echo "Checking for remote changes..."
|
||||
git fetch || die "fetch error"
|
||||
## git >= 1.8.5 has "pull --rebase=preserve"
|
||||
git rebase --preserve-merges || die "rebase error"
|
||||
|
||||
|
||||
echo "Pushing..."
|
||||
git push || die "push error"
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
### automerge ends here
|
Loading…
Add table
Reference in a new issue