merge-request.sh: Update 8.0 metabug for 8.0.1
[llvm-project.git] / llvm / utils / release / merge-request.sh
blob0a2bf7661fac3c1531f3cb9a526af5ad5127d7e5
1 # !/bin/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"
107 echo "error: invalid stable version"
108 exit 1
109 esac
110 bugzilla_version=$stable_version
112 if [ -z "$revisions" ]; then
113 echo "error: no revisions specified"
114 exit 1
117 if [ -z "$bugzilla_user" ]; then
118 echo "error: bugzilla username not specified."
119 exit 1
122 if [ -z "$BUGZILLA_BIN" ]; then
123 BUGZILLA_BIN=`which bugzilla`
124 if [ $? -ne 0 ]; then
125 echo "error: could not find bugzilla executable."
126 echo "Make sure the bugzilla cli tool is installed on your system: "
127 echo "pip install python-bugzilla (recommended)"
128 echo ""
129 echo "Fedora: dnf install python-bugzilla"
130 echo "Ubuntu/Debian: apt-get install bugzilla-cli"
131 exit 1
135 BUGZILLA_MAJOR_VERSION=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
137 if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
139 echo "***************************** Error ** ********************************"
140 echo "You are using an older version of the bugzilla cli tool, which is not "
141 echo "supported. You need to use bugzilla cli version 2.0.0 or higher:"
142 echo "***********************************************************************"
143 exit 1
146 BUGZILLA_CMD="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
148 rev_string=""
149 for r in $revisions; do
150 rev_string="$rev_string r$r"
151 done
153 echo "Checking for duplicate bugs..."
155 check_duplicates=`$BUGZILLA_CMD query --blocked=$release_metabug --field="cf_fixed_by_commits=$rev_string"`
157 if [ -n "$check_duplicates" ]; then
158 echo "Duplicate bug found:"
159 echo $check_duplicates
160 exit 1
163 echo "Done"
165 # Get short commit summary. To avoid having a huge summary, we just
166 # use the commit message for the first commit.
167 commit_summary=''
168 for r in $revisions; do
169 commit_msg=`svn log -r $r https://llvm.org/svn/llvm-project/`
170 if [ $? -ne 0 ]; then
171 echo "warning: failed to get commit message."
172 commit_msg=""
174 break
175 done
177 if [ -n "$commit_msg" ]; then
178 commit_summary=`echo "$commit_msg" | sed '4q;d' | cut -c1-80`
179 commit_summary=" : ${commit_summary}"
182 bug_summary="Merge${rev_string} into the $stable_version branch${commit_summary}"
184 set -x
186 # Login to bugzilla
187 $BUGZILLA_CMD login $bugzilla_user
189 bug_id=`${dryrun} $BUGZILLA_CMD --ensure-logged-in new \
190 -p "$bugzilla_product" \
191 -c "$bugzilla_component" --blocked=$release_metabug \
192 -o All --priority=P --arch All -v $bugzilla_version \
193 --field="cf_fixed_by_commits=$rev_string" \
194 --summary "${bug_summary}" \
195 -l "Is it OK to merge the following revision(s) to the $stable_version branch?" \
196 $bugzilla_assigned_to \
199 if [ -n "$dryrun" ]; then
200 exit 0
203 set +x
205 if [ -z "$bug_id" ]; then
206 echo "Failed to create bug."
207 exit 1
210 echo " Created new bug:"
211 echo https://llvm.org/PR$bug_id
213 # Add links to revisions
214 for r in $revisions; do
215 $BUGZILLA_CMD --ensure-logged-in modify -l "https://reviews.llvm.org/rL$r" $bug_id
216 done