Commit 5b29b688 authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Update git-replay-merge.sh script

parent 6d577430
Pipeline #8246 canceled with stages
in 4 minutes and 41 seconds
......@@ -16,6 +16,13 @@ SELF="${SELF/-/ }"
STATE_FILE=".git/REPLAY_MERGE"
DONT_PUSH=${DONT_PUSH:=false}
DONT_ACCEPT=${DONT_ACCEPT:=false}
GITLAB_API_ENDPOINT=${GITLAB_API_ENDPOINT:=https://gitlab.isc.org/api/v4}
GITLAB_URI=${GITLAB_URI:=$(echo $GITLAB_API_ENDPOINT | cut -f 1-3 -d /)}
GITLAB_PROJECT_ID=${GITLAB_PROJECT_ID:=1}
GITLAB_PROJECT_GROUP=${GITLAB_PROJECT_GROUP:=isc-projects}
GITLAB_PROJECT_NAME=${GITLAB_PROJECT_NAME:=bind9}
die() {
for MESSAGE in "$@"; do
......@@ -172,7 +179,22 @@ resume() {
REPLAY_COMMIT_TITLE="$(git show --format="%b" "${SOURCE_COMMIT}" 2>&1 | head -1)"
gitlab create_merge_request 1 "${REPLAY_COMMIT_TITLE}" "{source_branch: '${REPLAY_BRANCH}', target_branch: '${TARGET_BRANCH}'}"
MERGE_REQUEST_BASE_URI="${GITLAB_URI}/${GITLAB_PROJECT_GROUP}/${GITLAB_PROJECT_NAME}/merge_requests/"
MERGE_REQUEST_ID=$(gitlab create_merge_request "${GITLAB_PROJECT_ID}" "(${TARGET_BRANCH}) ${REPLAY_COMMIT_TITLE}" "{source_branch: '${REPLAY_BRANCH}', target_branch: '${TARGET_BRANCH}'}" | grep opened | cut -f 15 -d \| | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ -z "$MERGE_REQUEST_ID" ]]; then
die "Creating MR failed."
fi
REPLAY_HASH=$(git show-ref --hash --heads "${REPLAY_BRANCH}")
# gitlab accept_merge_request ${GITLAB_PROJECT_ID} ${MERGE_REQUEST_ID} "{should_remove_source_branch: true, merge_when_pipeline_succeeds: true, sha: '$REPLAY_HASH'}"
echo "================================================================================"
echo "=== Your new MR !${MERGE_REQUEST_ID} has been created"
echo "=== ${MERGE_REQUEST_BASE_URI}${MERGE_REQUEST_ID} ==="
echo "================================================================================"
cleanup
exit 0
......@@ -189,6 +211,8 @@ cleanup() {
rm -f "${STATE_FILE}"
}
cd $(git rev-parse --show-toplevel)
next_action="go"
while [[ $# -ge 1 ]]; do
case "$1" in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment