[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / llvm / utils / release / merge-request.sh
blob5cc7d1fb54e2bfe98bd47a2ffcacc81ae957417f
1 #!/usr/bin/env bash
2 #===-- merge-request.sh ---------------------------------------------------===#
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===------------------------------------------------------------------------===#
10 # Submit a merge request to bugzilla.
12 #===------------------------------------------------------------------------===#
14 dryrun=""
15 stable_version=""
16 revisions=""
17 BUGZILLA_BIN=""
18 BUGZILLA_CMD=""
19 release_metabug=""
20 bugzilla_product="new-bugs"
21 bugzilla_component="new bugs"
22 bugzilla_assigned_to=""
23 bugzilla_user=""
24 bugzilla_version=""
25 bugzilla_url="https://bugs.llvm.org/xmlrpc.cgi"
27 function usage() {
28 echo "usage: `basename $0` -user EMAIL -stable-version X.Y -r NUM"
29 echo ""
30 echo " -user EMAIL Your email address for logging into bugzilla."
31 echo " -stable-version X.Y The stable release version (e.g. 4.0, 5.0)."
32 echo " -r NUM Revision number to merge (e.g. 1234567)."
33 echo " This option can be specified multiple times."
34 echo " -bugzilla-bin PATH Path to bugzilla binary (optional)."
35 echo " -assign-to EMAIL Assign bug to user with EMAIL (optional)."
36 echo " -dry-run Print commands instead of executing them."
39 while [ $# -gt 0 ]; do
40 case $1 in
41 -user)
42 shift
43 bugzilla_user="$1"
45 -stable-version)
46 shift
47 stable_version="$1"
49 -r)
50 shift
51 revisions="$revisions $1"
53 -project)
54 shift
55 project="$1"
57 -component)
58 shift
59 bugzilla_component="$1"
61 -bugzilla-bin)
62 shift
63 BUGZILLA_BIN="$1"
65 -assign-to)
66 shift
67 bugzilla_assigned_to="--assigned_to=$1"
69 -dry-run)
70 dryrun="echo"
72 -help | --help | -h | --h | -\? )
73 usage
74 exit 0
76 * )
77 echo "unknown option: $1"
78 usage
79 exit 1
81 esac
82 shift
83 done
85 if [ -z "$stable_version" ]; then
86 echo "error: no stable version specified"
87 exit 1
90 case $stable_version in
91 4.0)
92 release_metabug="32061"
94 5.0)
95 release_metabug="34492"
97 6.0)
98 release_metabug="36649"
100 7.0)
101 release_metabug="39106"
103 8.0)
104 release_metabug="41221"
106 9.0)
107 release_metabug="43360"
110 echo "error: invalid stable version"
111 exit 1
112 esac
113 bugzilla_version=$stable_version
115 if [ -z "$revisions" ]; then
116 echo "error: no revisions specified"
117 exit 1
120 if [ -z "$bugzilla_user" ]; then
121 echo "error: bugzilla username not specified."
122 exit 1
125 if [ -z "$BUGZILLA_BIN" ]; then
126 BUGZILLA_BIN=`which bugzilla`
127 if [ $? -ne 0 ]; then
128 echo "error: could not find bugzilla executable."
129 echo "Make sure the bugzilla cli tool is installed on your system: "
130 echo "pip install python-bugzilla (recommended)"
131 echo ""
132 echo "Fedora: dnf install python-bugzilla"
133 echo "Ubuntu/Debian: apt-get install bugzilla-cli"
134 exit 1
138 BUGZILLA_MAJOR_VERSION=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
140 if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
142 echo "***************************** Error ** ********************************"
143 echo "You are using an older version of the bugzilla cli tool, which is not "
144 echo "supported. You need to use bugzilla cli version 2.0.0 or higher:"
145 echo "***********************************************************************"
146 exit 1
149 BUGZILLA_CMD="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
151 rev_string=""
152 for r in $revisions; do
153 rev_string="$rev_string r$r"
154 done
156 echo "Checking for duplicate bugs..."
158 check_duplicates=`$BUGZILLA_CMD query --blocked=$release_metabug --field="cf_fixed_by_commits=$rev_string"`
160 if [ -n "$check_duplicates" ]; then
161 echo "Duplicate bug found:"
162 echo $check_duplicates
163 exit 1
166 echo "Done"
168 # Get short commit summary. To avoid having a huge summary, we just
169 # use the commit message for the first commit.
170 commit_summary=''
171 for r in $revisions; do
172 commit_msg=`svn log -r $r https://llvm.org/svn/llvm-project/`
173 if [ $? -ne 0 ]; then
174 echo "warning: failed to get commit message."
175 commit_msg=""
177 break
178 done
180 if [ -n "$commit_msg" ]; then
181 commit_summary=`echo "$commit_msg" | sed '4q;d' | cut -c1-80`
182 commit_summary=" : ${commit_summary}"
185 bug_summary="Merge${rev_string} into the $stable_version branch${commit_summary}"
187 set -x
189 # Login to bugzilla
190 $BUGZILLA_CMD login $bugzilla_user
192 bug_id=`${dryrun} $BUGZILLA_CMD --ensure-logged-in new \
193 -p "$bugzilla_product" \
194 -c "$bugzilla_component" --blocked=$release_metabug \
195 -o All --priority=P --arch All -v $bugzilla_version \
196 --field="cf_fixed_by_commits=$rev_string" \
197 --summary "${bug_summary}" \
198 -l "Is it OK to merge the following revision(s) to the $stable_version branch?" \
199 $bugzilla_assigned_to \
202 if [ -n "$dryrun" ]; then
203 exit 0
206 set +x
208 if [ -z "$bug_id" ]; then
209 echo "Failed to create bug."
210 exit 1
213 echo " Created new bug:"
214 echo https://llvm.org/PR$bug_id
216 # Add links to revisions
217 for r in $revisions; do
218 $BUGZILLA_CMD --ensure-logged-in modify -l "https://reviews.llvm.org/rL$r" $bug_id
219 done