@@ -17,15 +17,10 @@ SELF="$(basename $0)"
17
17
SELF=" ${SELF/ -/ } "
18
18
19
19
STATE_FILE=" .git/REPLAY_MERGE"
20
+ DONT_TAG=${DONT_TAG:= false}
20
21
DONT_PUSH=${DONT_PUSH:= false}
21
22
DONT_ACCEPT=${DONT_ACCEPT:= false}
22
23
23
- GITLAB_API_ENDPOINT=${GITLAB_API_ENDPOINT:= https:// gitlab.isc.org/ api/ v4}
24
- GITLAB_URI=${GITLAB_URI:= $(echo $GITLAB_API_ENDPOINT | cut -f 1-3 -d / )}
25
- GITLAB_PROJECT_ID=${GITLAB_PROJECT_ID:= 1}
26
- GITLAB_PROJECT_GROUP=${GITLAB_PROJECT_GROUP:= isc-projects}
27
- GITLAB_PROJECT_NAME=${GITLAB_PROJECT_NAME:= bind9}
28
-
29
24
die () {
30
25
for MESSAGE in " $@ " ; do
31
26
echo -e " ${MESSAGE} " >&2
@@ -36,17 +31,14 @@ die() {
36
31
die_with_usage () {
37
32
die " Usage:" \
38
33
" " \
39
- " ${SELF} <merge_commit_id> <target_remote> <target_branch>" \
40
- " ${SELF} --no-push" \
41
- " ${SELF} --continue" \
42
- " ${SELF} --abort"
43
- }
44
-
45
- verify_gitlab_cli () {
46
- which gitlab > /dev/null 2>&1 || \
47
- die " You need to have gitlab cli installed and configured: " \
48
- " " \
49
- " $ gem install --user-install gitlab"
34
+ " ${SELF} [options] <merge_commit_id> <target_remote> <target_branch>" \
35
+ " ${SELF} --continue" \
36
+ " ${SELF} --abort" \
37
+ " " \
38
+ " options:" \
39
+ " --no-push" \
40
+ " --no-tag" \
41
+ " "
50
42
}
51
43
52
44
die_with_continue_instructions () {
@@ -173,21 +165,39 @@ resume() {
173
165
fi
174
166
fi
175
167
176
- if [[ " $DONT_PUSH " = " true " ]] ; then
168
+ if $DONT_PUSH ; then
177
169
die_before_push
178
170
fi
179
171
180
- if [[ " $DONT_ACCEPT " = " true " ]] ; then
181
- AUTOMERGE =" "
172
+ if $DONT_ACCEPT ; then
173
+ AUTO_MERGE =" "
182
174
else
183
- AUTO_MERGE=" -o merge_request.merge_when_pipeline_succeeds"
175
+ AUTO_MERGE=" merge_request.merge_when_pipeline_succeeds"
176
+ fi
177
+
178
+ TITLE=" "
179
+ LABEL_VERSION=" "
180
+ LABEL_BACKPORT=" "
181
+
182
+ if ! $DONT_TAG && [[ $TARGET_BRANCH == v9_[0-9][0-9] ]]; then
183
+
184
+ version=" 9.${TARGET_BRANCH# v9_} "
185
+
186
+ TITLE=" $( git show --format=%b ${SOURCE_COMMIT} | head -n 1) "
187
+ TITLE=" merge_request.title=[${version} ] ${TITLE} "
188
+
189
+ LABEL_VERSION=" merge_request.label=v${version} "
190
+ LABEL_BACKPORT=" merge_request.label=Backport"
184
191
fi
185
192
186
193
git push -u ${TARGET_REMOTE} \
187
194
-o merge_request.create \
188
195
-o merge_request.remove_source_branch \
189
196
-o " merge_request.target=${TARGET_BRANCH} " \
190
- ${AUTO_MERGE} \
197
+ ${AUTO_MERGE: +-o} " ${AUTO_MERGE} " \
198
+ ${TITLE: +-o} " ${TITLE} " \
199
+ ${LABEL_VERSION: +-o} " ${LABEL_VERSION} " \
200
+ ${LABEL_BACKPORT: +-o} " ${LABEL_BACKPORT} " \
191
201
" ${REPLAY_BRANCH} :${REPLAY_BRANCH} "
192
202
193
203
cleanup
@@ -208,6 +218,7 @@ cleanup() {
208
218
cd $( git rev-parse --show-toplevel)
209
219
210
220
next_action=" go"
221
+ args=3
211
222
while [[ $# -ge 1 ]]; do
212
223
case " $1 " in
213
224
" --no-push" )
@@ -216,29 +227,38 @@ while [[ $# -ge 1 ]]; do
216
227
" --push" )
217
228
DONT_PUSH=false
218
229
;;
230
+ " --no-tag" )
231
+ DONT_TAG=true
232
+ ;;
233
+ " --tag" )
234
+ DONT_TAG=false
235
+ ;;
219
236
" --abort" )
220
237
die_if_not_in_progress
221
238
source " ${STATE_FILE} "
222
239
next_action=" cleanup"
240
+ args=0
241
+ shift
242
+ break
223
243
;;
224
244
" --continue" )
225
- verify_gitlab_cli
226
245
die_if_not_in_progress
227
246
source " ${STATE_FILE} "
228
247
next_action=" resume"
229
- ;;
230
- * )
231
- if [[ $# -ne 3 ]]; then
232
- die_with_usage
233
- fi
248
+ args=0
249
+ shift
234
250
break
235
251
;;
252
+ --* ) die_with_usage
253
+ ;;
254
+ * ) break
255
+ ;;
236
256
esac
237
257
shift
238
258
done
239
259
240
- if [[ " DONT_PUSH " = " false " ]]; then
241
- verify_gitlab_cli
260
+ if [[ $# -ne $args ]]; then
261
+ die_with_usage
242
262
fi
243
263
244
264
$next_action " $@ "
0 commit comments