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