comparison utils/release/merge-request.sh @ 122:36195a0db682

merging ( incomplete )
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 17 Nov 2017 20:32:31 +0900
parents 803732b1fca8
children 3a76565eade5
comparison
equal deleted inserted replaced
119:d9df2cbd60cd 122:36195a0db682
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 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"
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 " 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."
38 }
39
40 while [ $# -gt 0 ]; do
41 case $1 in
42 -user)
43 shift
44 bugzilla_user="$1"
45 ;;
46 -stable-version)
47 shift
48 stable_version="$1"
49 ;;
50 -r)
51 shift
52 revisions="$revisions $1"
53 ;;
54 -project)
55 shift
56 project="$1"
57 ;;
58 -component)
59 shift
60 bugzilla_component="$1"
61 ;;
62 -bugzilla-bin)
63 shift
64 BUGZILLA_BIN="$1"
65 ;;
66 -assign-to)
67 shift
68 bugzilla_assigned_to="--assigned_to=$1"
69 ;;
70 -dry-run)
71 dryrun="echo"
72 ;;
73 -help | --help | -h | --h | -\? )
74 usage
75 exit 0
76 ;;
77 * )
78 echo "unknown option: $1"
79 usage
80 exit 1
81 ;;
82 esac
83 shift
84 done
85
86 if [ -z "$stable_version" ]; then
87 echo "error: no stable version specified"
88 exit 1
89 fi
90
91 case $stable_version in
92 4.0)
93 release_metabug="32061"
94 ;;
95 5.0)
96 release_metabug="34492"
97 ;;
98 *)
99 echo "error: invalid stable version"
100 exit 1
101 esac
102 bugzilla_version=$stable_version
103
104 if [ -z "$revisions" ]; then
105 echo "error: no revisions specified"
106 exit 1
107 fi
108
109 if [ -z "$bugzilla_user" ]; then
110 echo "error: bugzilla username not specified."
111 exit 1
112 fi
113
114 if [ -z "$BUGZILLA_BIN" ]; then
115 BUGZILLA_BIN=`which bugzilla`
116 if [ $? -ne 0 ]; then
117 echo "error: could not find bugzilla executable."
118 echo "Make sure the bugzilla cli tool is installed on your system: "
119 echo "pip install python-bugzilla (recommended)"
120 echo ""
121 echo "Fedora: dnf install python-bugzilla"
122 echo "Ubuntu/Debian: apt-get install bugzilla-cli"
123 exit 1
124 fi
125 fi
126
127 BUGZILLA_MAJOR_VERSION=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
128
129 if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
130
131 echo "***************************** Error ** ********************************"
132 echo "You are using an older version of the bugzilla cli tool, which is not "
133 echo "supported. You need to use bugzilla cli version 2.0.0 or higher:"
134 echo "***********************************************************************"
135 exit 1
136 fi
137
138 BUGZILLA_CMD="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
139
140 rev_string=""
141 for r in $revisions; do
142 rev_string="$rev_string r$r"
143 done
144
145 echo "Checking for duplicate bugs..."
146
147 check_duplicates=`$BUGZILLA_CMD query --blocked=$release_metabug --field="cf_fixed_by_commits=$rev_string"`
148
149 if [ -n "$check_duplicates" ]; then
150 echo "Duplicate bug found:"
151 echo $check_duplicates
152 exit 1
153 fi
154
155 echo "Done"
156
157 # Get short commit summary. To avoid having a huge summary, we just
158 # use the commit message for the first commit.
159 commit_summary=''
160 for r in $revisions; do
161 commit_msg=`svn log -r $r https://llvm.org/svn/llvm-project/`
162 if [ $? -ne 0 ]; then
163 echo "warning: failed to get commit message."
164 commit_msg=""
165 fi
166 break
167 done
168
169 if [ -n "$commit_msg" ]; then
170 commit_summary=`echo "$commit_msg" | sed '4q;d' | cut -c1-80`
171 commit_summary=" : ${commit_summary}"
172 fi
173
174 bug_summary="Merge${rev_string} into the $stable_version branch${commit_summary}"
175
176 set -x
177
178 # Login to bugzilla
179 $BUGZILLA_CMD login $bugzilla_user
180
181 bug_id=`${dryrun} $BUGZILLA_CMD --ensure-logged-in new \
182 -p "$bugzilla_product" \
183 -c "$bugzilla_component" --blocked=$release_metabug \
184 -o All --priority=P --arch All -v $bugzilla_version \
185 --field="cf_fixed_by_commits=$rev_string" \
186 --summary "${bug_summary}" \
187 -l "Is it OK to merge the following revision(s) to the $stable_version branch?" \
188 $bugzilla_assigned_to \
189 -i`
190
191 if [ -n "$dryrun" ]; then
192 exit 0
193 fi
194
195 set +x
196
197 if [ -z "$bug_id" ]; then
198 echo "Failed to create bug."
199 exit 1
200 fi
201
202 echo " Created new bug:"
203 echo https://llvm.org/PR$bug_id
204
205 # Add links to revisions
206 for r in $revisions; do
207 $BUGZILLA_CMD --ensure-logged-in modify -l "https://reviews.llvm.org/rL$r" $bug_id
208 done