blob: b0e88605ac0c68d781d7c6482c372cc71ebc0eab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#!/bin/sh -e
# Apply a pull request
# Copyright (C) 2014 Linaro Limited
# Author: Peter Maydell <peter.maydell@linaro.org>
# This work is licensed under the terms of the GNU GPL version 2 or later.
# Usage: apply-pullreq [options] remote-url remote-branch-or-tagname
#
# Valid options:
# --no-verify-sig : disable the gpg signature verification
# --submodule-ok : allow merges which change submodules
# (disabled by default to prevent accidental downgrades)
# This makes a bunch of assumptions about repo setup and
# preferred build-and-test commands.
VRFY=yes
SUBMODULE=no
if [ $# != 0 ] && [ "$1" = "--no-verify-sig" ]; then
shift
VRFY=no
fi
if [ $# != 0 ] && [ "$1" = "--submodule-ok" ]; then
shift
SUBMODULE=yes
fi
if [ $# != 2 ]; then
echo "Usage: apply-pullreq [options] remote-url branch-or-tagname"
exit 1
fi
REMOTEURL="$1"
REMOTETAG="$2"
# hard newline
NL='
'
BRANCH="$(git symbolic-ref -q HEAD || true)"
# NB that in the "detached head" case BRANCH will be the empty string
if [ "$BRANCH" != "refs/heads/staging" ]; then
echo "Must be on staging branch"
exit 1
fi
git checkout master
git pull
git checkout staging
if [ "$(git rev-parse master)" != "$(git rev-parse staging)" ]; then
echo "staging not up to date : suggest 'git reset --hard master'"
exit 1
fi
# Check we're not accidentally trying to merge after the
# final release was tagged and before we reopened the devtree.
VER="$(cat VERSION)"
VERMIN="${VER##*.}"
if [ "$VERMIN" = "0" ]; then
echo "VERSION says this a release version: forgot to reopen devtree?"
exit 1
fi
# Find the remote name corresponding to the URL. Note that we
# assume that any protocol on the remote is the same thing, and
# that a trailing ".git" makes no difference. This helps when
# submaintainers switch from specifying git:// to https:// and
# so on (particularly common with github URLs for some reason).
# trim leading protocol spec and trailing .git (if any)
REMURL=${REMOTEURL#*:}
REMURL=${REMURL%.git}
FGREPARG="$REMURL (fetch)$NL$REMURL.git (fetch)"
REMOTENAME="$(git remote -v | grep -F "$FGREPARG" | cut -f1)"
if [ -z "$REMOTENAME" ]; then
echo "Unknown remote $REMOTEURL: add manually via"
echo "add-merge-remote REMOTENAME $REMOTEURL"
exit 1
fi
echo "fetching from remote $REMOTENAME"
git fetch "$REMOTENAME"
if [ "$VRFY" = "yes" ]; then
if ! git verify-tag "remotes/$REMOTENAME/$REMOTETAG"; then
echo "Does not appear to be a signed tag"
echo "(use --no-verify-sig to override)"
exit 1
fi
fi
echo "merging..."
git merge --no-edit --no-ff --log "remotes/$REMOTENAME/$REMOTETAG"
# Edit the merge commit to add our signoff line
git commit --amend --signoff --no-edit
# Check whether there seems to be a submodule update here. NB that this
# can have false positives..
if git diff master..staging | grep -q 'Subproject commit'; then
if [ "$SUBMODULE" = "no" ]; then
echo "ERROR: pull request includes submodule update"
echo "(use --submodule-ok to override)"
exit 1
fi
echo "WARNING: pull appears to include submodule update, please check it!"
fi
# Check whether any authors needs to be corrected after SPF rewrites
if git shortlog --author=qemu-devel@nongnu.org master..staging | grep .; then
echo "ERROR: pull request includes commits attributed to list"
exit 1
fi
# This should exit with an error status if any of the sub-builds fails.
parallel-buildtest
echo "WARNING: please check these results files!"
echo "Looks good; trying a dry-run publish:"
git push --dry-run publish-upstream staging:master
# For obvious reasons we don't let the script automatically
# do the publish to upstream master...
echo "OK; to publish for real run:"
echo "git push publish-upstream staging:master"
|