annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 # !/bin/bash
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 #===-- merge-request.sh ---------------------------------------------------===#
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 #
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 # The LLVM Compiler Infrastructure
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 #
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 # This file is distributed under the University of Illinois Open Source
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 # License.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 #
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 #===------------------------------------------------------------------------===#
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 #
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 # Submit a merge request to bugzilla.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 #
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 #===------------------------------------------------------------------------===#
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 dryrun=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16 stable_version=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 revisions=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 BUGZILLA_BIN=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19 BUGZILLA_CMD=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 release_metabug=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 bugzilla_product="new-bugs"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 bugzilla_component="new bugs"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 bugzilla_assigned_to=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 bugzilla_user=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 bugzilla_version=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26 bugzilla_url="https://bugs.llvm.org/xmlrpc.cgi"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 function usage() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 echo "usage: `basename $0` -user EMAIL -stable-version X.Y -r NUM"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 echo ""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 echo " -user EMAIL Your email address for logging into bugzilla."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 echo " -stable-version X.Y The stable release version (e.g. 4.0, 5.0)."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 echo " -r NUM Revision number to merge (e.g. 1234567)."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 echo " This option can be specified multiple times."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 echo " -bugzilla-bin PATH Path to bugzilla binary (optional)."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 echo " -assign-to EMAIL Assign bug to user with EMAIL (optional)."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 echo " -dry-run Print commands instead of executing them."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 while [ $# -gt 0 ]; do
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 case $1 in
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42 -user)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 bugzilla_user="$1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 -stable-version)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 stable_version="$1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50 -r)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
51 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52 revisions="$revisions $1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
54 -project)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
55 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
56 project="$1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
57 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
58 -component)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
59 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
60 bugzilla_component="$1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
61 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
62 -bugzilla-bin)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
63 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
64 BUGZILLA_BIN="$1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
65 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
66 -assign-to)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
67 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
68 bugzilla_assigned_to="--assigned_to=$1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
69 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
70 -dry-run)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
71 dryrun="echo"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
72 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
73 -help | --help | -h | --h | -\? )
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
74 usage
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
75 exit 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
76 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
77 * )
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
78 echo "unknown option: $1"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
79 usage
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
80 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
81 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
82 esac
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
83 shift
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
84 done
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
85
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
86 if [ -z "$stable_version" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
87 echo "error: no stable version specified"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
88 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
89 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
90
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
91 case $stable_version in
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
92 4.0)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
93 release_metabug="32061"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
94 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
95 5.0)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
96 release_metabug="34492"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
97 ;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
98 *)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
99 echo "error: invalid stable version"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
100 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
101 esac
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
102 bugzilla_version=$stable_version
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
103
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
104 if [ -z "$revisions" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
105 echo "error: no revisions specified"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
106 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
107 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
108
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
109 if [ -z "$bugzilla_user" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
110 echo "error: bugzilla username not specified."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
111 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
112 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
113
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
114 if [ -z "$BUGZILLA_BIN" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
115 BUGZILLA_BIN=`which bugzilla`
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
116 if [ $? -ne 0 ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
117 echo "error: could not find bugzilla executable."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
118 echo "Make sure the bugzilla cli tool is installed on your system: "
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
119 echo "pip install python-bugzilla (recommended)"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
120 echo ""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
121 echo "Fedora: dnf install python-bugzilla"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
122 echo "Ubuntu/Debian: apt-get install bugzilla-cli"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
123 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
124 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
125 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
126
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
127 BUGZILLA_MAJOR_VERSION=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
128
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
129 if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
130
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
131 echo "***************************** Error ** ********************************"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
132 echo "You are using an older version of the bugzilla cli tool, which is not "
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
133 echo "supported. You need to use bugzilla cli version 2.0.0 or higher:"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
134 echo "***********************************************************************"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
135 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
136 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
137
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
138 BUGZILLA_CMD="$BUGZILLA_BIN --bugzilla=$bugzilla_url"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
139
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
140 rev_string=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
141 for r in $revisions; do
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
142 rev_string="$rev_string r$r"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
143 done
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
144
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
145 echo "Checking for duplicate bugs..."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
146
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
147 check_duplicates=`$BUGZILLA_CMD query --blocked=$release_metabug --field="cf_fixed_by_commits=$rev_string"`
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
148
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
149 if [ -n "$check_duplicates" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
150 echo "Duplicate bug found:"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
151 echo $check_duplicates
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
152 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
153 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
154
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
155 echo "Done"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
156
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
157 # Get short commit summary. To avoid having a huge summary, we just
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
158 # use the commit message for the first commit.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
159 commit_summary=''
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
160 for r in $revisions; do
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
161 commit_msg=`svn log -r $r https://llvm.org/svn/llvm-project/`
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
162 if [ $? -ne 0 ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
163 echo "warning: failed to get commit message."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
164 commit_msg=""
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
165 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
166 break
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
167 done
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
168
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
169 if [ -n "$commit_msg" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
170 commit_summary=`echo "$commit_msg" | sed '4q;d' | cut -c1-80`
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
171 commit_summary=" : ${commit_summary}"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
172 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
173
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
174 bug_summary="Merge${rev_string} into the $stable_version branch${commit_summary}"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
175
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
176 set -x
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
177
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
178 # Login to bugzilla
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
179 $BUGZILLA_CMD login $bugzilla_user
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
180
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
181 bug_id=`${dryrun} $BUGZILLA_CMD --ensure-logged-in new \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
182 -p "$bugzilla_product" \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
183 -c "$bugzilla_component" --blocked=$release_metabug \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
184 -o All --priority=P --arch All -v $bugzilla_version \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
185 --field="cf_fixed_by_commits=$rev_string" \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
186 --summary "${bug_summary}" \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
187 -l "Is it OK to merge the following revision(s) to the $stable_version branch?" \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
188 $bugzilla_assigned_to \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
189 -i`
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
190
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
191 if [ -n "$dryrun" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
192 exit 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
193 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
194
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
195 set +x
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
196
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
197 if [ -z "$bug_id" ]; then
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
198 echo "Failed to create bug."
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
199 exit 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
200 fi
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
201
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
202 echo " Created new bug:"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
203 echo https://llvm.org/PR$bug_id
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
204
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
205 # Add links to revisions
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
206 for r in $revisions; do
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
207 $BUGZILLA_CMD --ensure-logged-in modify -l "https://reviews.llvm.org/rL$r" $bug_id
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
208 done