[llvm-exegesis] Fix missing std::move.
[llvm-complete.git] / utils / release / merge-request.sh
blob333b9043af356a8faf1aa16f5ae07a1d6d4088ee
1 # !/bin/bash
2 #===-- merge-request.sh ---------------------------------------------------===#
4 # The LLVM Compiler Infrastructure
6 # This file is distributed under the University of Illinois Open Source
7 # License.
9 #===------------------------------------------------------------------------===#
11 # Submit a merge request to bugzilla.
13 #===------------------------------------------------------------------------===#
15 dryrun=""
16 stable_version=""
17 revisions=""
18 BUGZILLA_BIN=""
19 BUGZILLA_CMD=""
20 release_metabug=""
21 bugzilla_product="new-bugs"
22 bugzilla_component="new bugs"
23 bugzilla_assigned_to=""
24 bugzilla_user=""
25 bugzilla_version=""
26 bugzilla_url="https://bugs.llvm.org/xmlrpc.cgi"
28 function usage() {
29 echo "usage: `basename $0` -user EMAIL -stable-version X.Y -r NUM"
30 echo ""
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
41 case $1 in
42 -user)
43 shift
44 bugzilla_user="$1"
46 -stable-version)
47 shift
48 stable_version="$1"
50 -r)
51 shift
52 revisions="$revisions $1"
54 -project)
55 shift
56 project="$1"
58 -component)
59 shift
60 bugzilla_component="$1"
62 -bugzilla-bin)
63 shift
64 BUGZILLA_BIN="$1"
66 -assign-to)
67 shift
68 bugzilla_assigned_to="--assigned_to=$1"
70 -dry-run)
71 dryrun="echo"
73 -help | --help | -h | --h | -\? )
74 usage
75 exit 0
77 * )
78 echo "unknown option: $1"
79 usage
80 exit 1
82 esac
83 shift
84 done
86 if [ -z "$stable_version" ]; then
87 echo "error: no stable version specified"
88 exit 1
91 case $stable_version in
92 4.0)
93 release_metabug="32061"
95 5.0)
96 release_metabug="34492"
98 6.0)
99 release_metabug="36649"
101 7.0)
102 release_metabug="39106"
105 echo "error: invalid stable version"
106 exit 1
107 esac
108 bugzilla_version=$stable_version
110 if [ -z "$revisions" ]; then
111 echo "error: no revisions specified"
112 exit 1
115 if [ -z "$bugzilla_user" ]; then
116 echo "error: bugzilla username not specified."
117 exit 1
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)"
126 echo ""
127 echo "Fedora: dnf install python-bugzilla"
128 echo "Ubuntu/Debian: apt-get install bugzilla-cli"
129 exit 1
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 "***********************************************************************"
141 exit 1
144 BUGZILLA_CMD="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
146 rev_string=""
147 for r in $revisions; do
148 rev_string="$rev_string r$r"
149 done
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
158 exit 1
161 echo "Done"
163 # Get short commit summary. To avoid having a huge summary, we just
164 # use the commit message for the first commit.
165 commit_summary=''
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."
170 commit_msg=""
172 break
173 done
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}"
182 set -x
184 # Login to bugzilla
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
198 exit 0
201 set +x
203 if [ -z "$bug_id" ]; then
204 echo "Failed to create bug."
205 exit 1
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
214 done