2019-08-23 07:42:31 +08:00
|
|
|
#!/usr/bin/env bash
|
2017-03-25 00:13:18 +08:00
|
|
|
#===-- merge-request.sh ---------------------------------------------------===#
|
|
|
|
#
|
2019-01-19 16:50:56 +08:00
|
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-03-25 00:13:18 +08:00
|
|
|
#
|
|
|
|
#===------------------------------------------------------------------------===#
|
|
|
|
#
|
|
|
|
# Submit a merge request to bugzilla.
|
|
|
|
#
|
|
|
|
#===------------------------------------------------------------------------===#
|
|
|
|
|
|
|
|
dryrun=""
|
|
|
|
stable_version=""
|
2017-09-15 10:25:22 +08:00
|
|
|
revisions=""
|
2017-03-25 00:13:18 +08:00
|
|
|
BUGZILLA_BIN=""
|
|
|
|
BUGZILLA_CMD=""
|
|
|
|
release_metabug=""
|
|
|
|
bugzilla_product="new-bugs"
|
|
|
|
bugzilla_component="new bugs"
|
|
|
|
bugzilla_assigned_to=""
|
|
|
|
bugzilla_user=""
|
|
|
|
bugzilla_version=""
|
2017-05-24 04:35:38 +08:00
|
|
|
bugzilla_url="https://bugs.llvm.org/xmlrpc.cgi"
|
2017-03-25 00:13:18 +08:00
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo "usage: `basename $0` -user EMAIL -stable-version X.Y -r NUM"
|
|
|
|
echo ""
|
|
|
|
echo " -user EMAIL Your email address for logging into bugzilla."
|
|
|
|
echo " -stable-version X.Y The stable release version (e.g. 4.0, 5.0)."
|
|
|
|
echo " -r NUM Revision number to merge (e.g. 1234567)."
|
2017-09-15 10:25:22 +08:00
|
|
|
echo " This option can be specified multiple times."
|
2017-03-25 00:13:18 +08:00
|
|
|
echo " -bugzilla-bin PATH Path to bugzilla binary (optional)."
|
|
|
|
echo " -assign-to EMAIL Assign bug to user with EMAIL (optional)."
|
|
|
|
echo " -dry-run Print commands instead of executing them."
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
-user)
|
|
|
|
shift
|
|
|
|
bugzilla_user="$1"
|
|
|
|
;;
|
|
|
|
-stable-version)
|
|
|
|
shift
|
|
|
|
stable_version="$1"
|
|
|
|
;;
|
|
|
|
-r)
|
|
|
|
shift
|
2017-09-15 10:25:22 +08:00
|
|
|
revisions="$revisions $1"
|
2017-03-25 00:13:18 +08:00
|
|
|
;;
|
|
|
|
-project)
|
|
|
|
shift
|
|
|
|
project="$1"
|
|
|
|
;;
|
|
|
|
-component)
|
|
|
|
shift
|
|
|
|
bugzilla_component="$1"
|
|
|
|
;;
|
|
|
|
-bugzilla-bin)
|
|
|
|
shift
|
|
|
|
BUGZILLA_BIN="$1"
|
|
|
|
;;
|
|
|
|
-assign-to)
|
|
|
|
shift
|
|
|
|
bugzilla_assigned_to="--assigned_to=$1"
|
|
|
|
;;
|
|
|
|
-dry-run)
|
|
|
|
dryrun="echo"
|
|
|
|
;;
|
|
|
|
-help | --help | -h | --h | -\? )
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "unknown option: $1"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$stable_version" ]; then
|
|
|
|
echo "error: no stable version specified"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $stable_version in
|
|
|
|
4.0)
|
|
|
|
release_metabug="32061"
|
|
|
|
;;
|
2017-09-15 10:25:22 +08:00
|
|
|
5.0)
|
|
|
|
release_metabug="34492"
|
|
|
|
;;
|
2018-01-04 02:51:22 +08:00
|
|
|
6.0)
|
2018-03-09 00:29:08 +08:00
|
|
|
release_metabug="36649"
|
2018-01-04 02:51:22 +08:00
|
|
|
;;
|
2018-09-28 10:30:42 +08:00
|
|
|
7.0)
|
|
|
|
release_metabug="39106"
|
|
|
|
;;
|
2019-01-30 09:10:47 +08:00
|
|
|
8.0)
|
2019-03-26 01:01:29 +08:00
|
|
|
release_metabug="41221"
|
2019-01-30 09:10:47 +08:00
|
|
|
;;
|
2019-08-21 21:42:10 +08:00
|
|
|
9.0)
|
2019-10-14 06:10:06 +08:00
|
|
|
release_metabug="43360"
|
2019-08-21 21:42:10 +08:00
|
|
|
;;
|
2017-03-25 00:13:18 +08:00
|
|
|
*)
|
|
|
|
echo "error: invalid stable version"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
bugzilla_version=$stable_version
|
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
if [ -z "$revisions" ]; then
|
|
|
|
echo "error: no revisions specified"
|
2017-03-25 00:13:18 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$bugzilla_user" ]; then
|
|
|
|
echo "error: bugzilla username not specified."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$BUGZILLA_BIN" ]; then
|
|
|
|
BUGZILLA_BIN=`which bugzilla`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "error: could not find bugzilla executable."
|
|
|
|
echo "Make sure the bugzilla cli tool is installed on your system: "
|
|
|
|
echo "pip install python-bugzilla (recommended)"
|
|
|
|
echo ""
|
|
|
|
echo "Fedora: dnf install python-bugzilla"
|
|
|
|
echo "Ubuntu/Debian: apt-get install bugzilla-cli"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
BUGZILLA_MAJOR_VERSION=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
|
|
|
|
|
|
|
|
if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
|
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
echo "***************************** Error ** ********************************"
|
|
|
|
echo "You are using an older version of the bugzilla cli tool, which is not "
|
|
|
|
echo "supported. You need to use bugzilla cli version 2.0.0 or higher:"
|
|
|
|
echo "***********************************************************************"
|
|
|
|
exit 1
|
2017-03-25 00:13:18 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
BUGZILLA_CMD="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
|
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
rev_string=""
|
|
|
|
for r in $revisions; do
|
|
|
|
rev_string="$rev_string r$r"
|
|
|
|
done
|
2017-03-25 00:13:18 +08:00
|
|
|
|
|
|
|
echo "Checking for duplicate bugs..."
|
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
check_duplicates=`$BUGZILLA_CMD query --blocked=$release_metabug --field="cf_fixed_by_commits=$rev_string"`
|
2017-03-25 00:13:18 +08:00
|
|
|
|
|
|
|
if [ -n "$check_duplicates" ]; then
|
|
|
|
echo "Duplicate bug found:"
|
|
|
|
echo $check_duplicates
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Done"
|
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
# Get short commit summary. To avoid having a huge summary, we just
|
|
|
|
# use the commit message for the first commit.
|
2017-03-25 00:13:18 +08:00
|
|
|
commit_summary=''
|
2017-09-15 10:25:22 +08:00
|
|
|
for r in $revisions; do
|
|
|
|
commit_msg=`svn log -r $r https://llvm.org/svn/llvm-project/`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "warning: failed to get commit message."
|
|
|
|
commit_msg=""
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
done
|
2017-03-25 00:13:18 +08:00
|
|
|
|
|
|
|
if [ -n "$commit_msg" ]; then
|
|
|
|
commit_summary=`echo "$commit_msg" | sed '4q;d' | cut -c1-80`
|
|
|
|
commit_summary=" : ${commit_summary}"
|
|
|
|
fi
|
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
bug_summary="Merge${rev_string} into the $stable_version branch${commit_summary}"
|
2017-03-25 00:13:18 +08:00
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
set -x
|
|
|
|
|
|
|
|
# Login to bugzilla
|
|
|
|
$BUGZILLA_CMD login $bugzilla_user
|
2017-03-25 00:13:18 +08:00
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
bug_id=`${dryrun} $BUGZILLA_CMD --ensure-logged-in new \
|
2017-03-25 00:13:18 +08:00
|
|
|
-p "$bugzilla_product" \
|
2017-09-15 10:25:22 +08:00
|
|
|
-c "$bugzilla_component" --blocked=$release_metabug \
|
2017-03-25 00:13:18 +08:00
|
|
|
-o All --priority=P --arch All -v $bugzilla_version \
|
2017-09-15 10:25:22 +08:00
|
|
|
--field="cf_fixed_by_commits=$rev_string" \
|
2017-03-25 00:13:18 +08:00
|
|
|
--summary "${bug_summary}" \
|
2017-09-15 10:25:22 +08:00
|
|
|
-l "Is it OK to merge the following revision(s) to the $stable_version branch?" \
|
2017-03-25 00:13:18 +08:00
|
|
|
$bugzilla_assigned_to \
|
2017-09-15 10:25:22 +08:00
|
|
|
-i`
|
2017-03-25 00:13:18 +08:00
|
|
|
|
|
|
|
if [ -n "$dryrun" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
set +x
|
2017-03-25 00:13:18 +08:00
|
|
|
|
2017-09-15 10:25:22 +08:00
|
|
|
if [ -z "$bug_id" ]; then
|
|
|
|
echo "Failed to create bug."
|
|
|
|
exit 1
|
2017-03-25 00:13:18 +08:00
|
|
|
fi
|
2017-09-15 10:25:22 +08:00
|
|
|
|
|
|
|
echo " Created new bug:"
|
|
|
|
echo https://llvm.org/PR$bug_id
|
|
|
|
|
|
|
|
# Add links to revisions
|
|
|
|
for r in $revisions; do
|
|
|
|
$BUGZILLA_CMD --ensure-logged-in modify -l "https://reviews.llvm.org/rL$r" $bug_id
|
|
|
|
done
|