2 #===-- merge-request.sh ---------------------------------------------------===#
4 # The LLVM Compiler Infrastructure
6 # This file is distributed under the University of Illinois Open Source
9 #===------------------------------------------------------------------------===#
11 # Submit a merge request to bugzilla.
13 #===------------------------------------------------------------------------===#
21 bugzilla_product
="new-bugs"
22 bugzilla_component
="new bugs"
23 bugzilla_assigned_to
=""
26 bugzilla_url
="https://bugs.llvm.org/xmlrpc.cgi"
29 echo "usage: `basename $0` -user EMAIL -stable-version X.Y -r NUM"
31 echo " -user EMAIL Your email address for logging into bugzilla."
32 echo " -stable-version X.Y The stable release version (e.g. 4.0, 5.0)."
33 echo " -r NUM Revision number to merge (e.g. 1234567)."
34 echo " This option can be specified multiple times."
35 echo " -bugzilla-bin PATH Path to bugzilla binary (optional)."
36 echo " -assign-to EMAIL Assign bug to user with EMAIL (optional)."
37 echo " -dry-run Print commands instead of executing them."
40 while [ $# -gt 0 ]; do
52 revisions
="$revisions $1"
60 bugzilla_component
="$1"
68 bugzilla_assigned_to
="--assigned_to=$1"
73 -help |
--help |
-h |
--h |
-\? )
78 echo "unknown option: $1"
86 if [ -z "$stable_version" ]; then
87 echo "error: no stable version specified"
91 case $stable_version in
93 release_metabug
="32061"
96 release_metabug
="34492"
99 release_metabug
="36649"
102 release_metabug
="39106"
105 echo "error: invalid stable version"
108 bugzilla_version
=$stable_version
110 if [ -z "$revisions" ]; then
111 echo "error: no revisions specified"
115 if [ -z "$bugzilla_user" ]; then
116 echo "error: bugzilla username not specified."
120 if [ -z "$BUGZILLA_BIN" ]; then
121 BUGZILLA_BIN
=`which bugzilla`
122 if [ $?
-ne 0 ]; then
123 echo "error: could not find bugzilla executable."
124 echo "Make sure the bugzilla cli tool is installed on your system: "
125 echo "pip install python-bugzilla (recommended)"
127 echo "Fedora: dnf install python-bugzilla"
128 echo "Ubuntu/Debian: apt-get install bugzilla-cli"
133 BUGZILLA_MAJOR_VERSION
=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
135 if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
137 echo "***************************** Error ** ********************************"
138 echo "You are using an older version of the bugzilla cli tool, which is not "
139 echo "supported. You need to use bugzilla cli version 2.0.0 or higher:"
140 echo "***********************************************************************"
144 BUGZILLA_CMD
="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
147 for r
in $revisions; do
148 rev_string
="$rev_string r$r"
151 echo "Checking for duplicate bugs..."
153 check_duplicates
=`$BUGZILLA_CMD query --blocked=$release_metabug --field="cf_fixed_by_commits=$rev_string"`
155 if [ -n "$check_duplicates" ]; then
156 echo "Duplicate bug found:"
157 echo $check_duplicates
163 # Get short commit summary. To avoid having a huge summary, we just
164 # use the commit message for the first commit.
166 for r
in $revisions; do
167 commit_msg
=`svn log -r $r https://llvm.org/svn/llvm-project/`
168 if [ $?
-ne 0 ]; then
169 echo "warning: failed to get commit message."
175 if [ -n "$commit_msg" ]; then
176 commit_summary
=`echo "$commit_msg" | sed '4q;d' | cut -c1-80`
177 commit_summary
=" : ${commit_summary}"
180 bug_summary
="Merge${rev_string} into the $stable_version branch${commit_summary}"
185 $BUGZILLA_CMD login
$bugzilla_user
187 bug_id
=`${dryrun} $BUGZILLA_CMD --ensure-logged-in new \
188 -p "$bugzilla_product" \
189 -c "$bugzilla_component" --blocked=$release_metabug \
190 -o All --priority=P --arch All -v $bugzilla_version \
191 --field="cf_fixed_by_commits=$rev_string" \
192 --summary "${bug_summary}" \
193 -l "Is it OK to merge the following revision(s) to the $stable_version branch?" \
194 $bugzilla_assigned_to \
197 if [ -n "$dryrun" ]; then
203 if [ -z "$bug_id" ]; then
204 echo "Failed to create bug."
208 echo " Created new bug:"
209 echo https
://llvm.org
/PR
$bug_id
211 # Add links to revisions
212 for r
in $revisions; do
213 $BUGZILLA_CMD --ensure-logged-in modify
-l "https://reviews.llvm.org/rL$r" $bug_id