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 #===------------------------------------------------------------------------===#
20 bugzilla_product
="new-bugs"
21 bugzilla_component
="new bugs"
22 bugzilla_assigned_to
=""
25 bugzilla_url
="https://bugs.llvm.org/xmlrpc.cgi"
28 echo "usage: `basename $0` -user EMAIL -stable-version X.Y -r NUM"
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
51 revisions
="$revisions $1"
59 bugzilla_component
="$1"
67 bugzilla_assigned_to
="--assigned_to=$1"
72 -help |
--help |
-h |
--h |
-\? )
77 echo "unknown option: $1"
85 if [ -z "$stable_version" ]; then
86 echo "error: no stable version specified"
90 case $stable_version in
92 release_metabug
="32061"
95 release_metabug
="34492"
98 release_metabug
="36649"
101 release_metabug
="39106"
104 release_metabug
="41221"
107 release_metabug
="43360"
110 echo "error: invalid stable version"
113 bugzilla_version
=$stable_version
115 if [ -z "$revisions" ]; then
116 echo "error: no revisions specified"
120 if [ -z "$bugzilla_user" ]; then
121 echo "error: bugzilla username not specified."
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)"
132 echo "Fedora: dnf install python-bugzilla"
133 echo "Ubuntu/Debian: apt-get install bugzilla-cli"
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 "***********************************************************************"
149 BUGZILLA_CMD
="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
152 for r
in $revisions; do
153 rev_string
="$rev_string r$r"
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
168 # Get short commit summary. To avoid having a huge summary, we just
169 # use the commit message for the first commit.
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."
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}"
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
208 if [ -z "$bug_id" ]; then
209 echo "Failed to create bug."
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