Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit c1a0cfc

Browse files
committed
Merging r298705:
------------------------------------------------------------------------ r298705 | tstellar | 2017-03-24 12:13:18 -0400 (Fri, 24 Mar 2017) | 11 lines stable-merge-request.sh: Add a script for submitting merge requests via bugzilla Summary: This script will automatically create a new stable merge request bug in bugzilla for the given svn revision and release number. Reviewers: hans Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30905 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@299455 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e7bfbb7 commit c1a0cfc

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed

utils/release/merge-request.sh

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# !/bin/bash
2+
#===-- merge-request.sh ---------------------------------------------------===#
3+
#
4+
# The LLVM Compiler Infrastructure
5+
#
6+
# This file is distributed under the University of Illinois Open Source
7+
# License.
8+
#
9+
#===------------------------------------------------------------------------===#
10+
#
11+
# Submit a merge request to bugzilla.
12+
#
13+
#===------------------------------------------------------------------------===#
14+
15+
dryrun=""
16+
stable_version=""
17+
revision=""
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="http://bugs.llvm.org/xmlrpc.cgi"
27+
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 " -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."
37+
}
38+
39+
while [ $# -gt 0 ]; do
40+
case $1 in
41+
-user)
42+
shift
43+
bugzilla_user="$1"
44+
;;
45+
-stable-version)
46+
shift
47+
stable_version="$1"
48+
;;
49+
-r)
50+
shift
51+
revision="$1"
52+
;;
53+
-project)
54+
shift
55+
project="$1"
56+
;;
57+
-component)
58+
shift
59+
bugzilla_component="$1"
60+
;;
61+
-bugzilla-bin)
62+
shift
63+
BUGZILLA_BIN="$1"
64+
;;
65+
-assign-to)
66+
shift
67+
bugzilla_assigned_to="--assigned_to=$1"
68+
;;
69+
-dry-run)
70+
dryrun="echo"
71+
;;
72+
-help | --help | -h | --h | -\? )
73+
usage
74+
exit 0
75+
;;
76+
* )
77+
echo "unknown option: $1"
78+
usage
79+
exit 1
80+
;;
81+
esac
82+
shift
83+
done
84+
85+
if [ -z "$stable_version" ]; then
86+
echo "error: no stable version specified"
87+
exit 1
88+
fi
89+
90+
case $stable_version in
91+
4.0)
92+
release_metabug="32061"
93+
;;
94+
*)
95+
echo "error: invalid stable version"
96+
exit 1
97+
esac
98+
bugzilla_version=$stable_version
99+
100+
if [ -z "$revision" ]; then
101+
echo "error: revision not specified"
102+
exit 1
103+
fi
104+
105+
if [ -z "$bugzilla_user" ]; then
106+
echo "error: bugzilla username not specified."
107+
exit 1
108+
fi
109+
110+
if [ -z "$BUGZILLA_BIN" ]; then
111+
BUGZILLA_BIN=`which bugzilla`
112+
if [ $? -ne 0 ]; then
113+
echo "error: could not find bugzilla executable."
114+
echo "Make sure the bugzilla cli tool is installed on your system: "
115+
echo "pip install python-bugzilla (recommended)"
116+
echo ""
117+
echo "Fedora: dnf install python-bugzilla"
118+
echo "Ubuntu/Debian: apt-get install bugzilla-cli"
119+
exit 1
120+
fi
121+
fi
122+
123+
BUGZILLA_MAJOR_VERSION=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
124+
125+
if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
126+
127+
echo "***************************** Warning *******************************"
128+
echo "You are using an older version of the bugzilla cli tool. You will be "
129+
echo "able to create bugs, but this script will crash with the following "
130+
echo "error when trying to read back information about the bug you created:"
131+
echo ""
132+
echo "KeyError: 'internals'"
133+
echo ""
134+
echo "To avoid this error, use version 2.0.0 or higher"
135+
echo "https://pypi.python.org/pypi/python-bugzilla"
136+
echo "*********************************************************************"
137+
fi
138+
139+
BUGZILLA_CMD="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
140+
141+
bug_url="https://reviews.llvm.org/rL$revision"
142+
143+
echo "Checking for duplicate bugs..."
144+
145+
check_duplicates=`$BUGZILLA_CMD query --url $bug_url`
146+
147+
if [ -n "$check_duplicates" ]; then
148+
echo "Duplicate bug found:"
149+
echo $check_duplicates
150+
exit 1
151+
fi
152+
153+
echo "Done"
154+
155+
# Get short commit summary
156+
commit_summary=''
157+
commit_msg=`svn log -r $revision https://llvm.org/svn/llvm-project/`
158+
if [ $? -ne 0 ]; then
159+
echo "warning: failed to get commit message."
160+
commit_msg=""
161+
fi
162+
163+
if [ -n "$commit_msg" ]; then
164+
commit_summary=`echo "$commit_msg" | sed '4q;d' | cut -c1-80`
165+
commit_summary=" : ${commit_summary}"
166+
fi
167+
168+
bug_summary="Merge r$revision into the $stable_version branch${commit_summary}"
169+
170+
if [ -z "$dryrun" ]; then
171+
set -x
172+
fi
173+
174+
${dryrun} $BUGZILLA_CMD --login --user=$bugzilla_user new \
175+
-p "$bugzilla_product" \
176+
-c "$bugzilla_component" -u $bug_url --blocked=$release_metabug \
177+
-o All --priority=P --arch All -v $bugzilla_version \
178+
--summary "${bug_summary}" \
179+
-l "Is this patch OK to merge to the $stable_version branch?" \
180+
$bugzilla_assigned_to \
181+
--oneline
182+
183+
set +x
184+
185+
if [ -n "$dryrun" ]; then
186+
exit 0
187+
fi
188+
189+
if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
190+
success=`$BUGZILLA_CMD query --url $bug_url`
191+
if [ -z "$success" ]; then
192+
echo "Failed to create bug."
193+
exit 1
194+
fi
195+
196+
echo " Created new bug:"
197+
echo $success
198+
fi

0 commit comments

Comments
 (0)