mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
Merge branch 'ondrej/update-git-replay-merge' into 'master'
Update the git-replay-merge to use the latest GitLab -o options See merge request isc-projects/bind9!2503
This commit is contained in:
@@ -14,6 +14,7 @@ set -e
|
|||||||
SELF="$(basename $0)"
|
SELF="$(basename $0)"
|
||||||
SELF="${SELF/-/ }"
|
SELF="${SELF/-/ }"
|
||||||
|
|
||||||
|
STATE_FILE=".git/REPLAY_MERGE"
|
||||||
DONT_PUSH=${DONT_PUSH:=false}
|
DONT_PUSH=${DONT_PUSH:=false}
|
||||||
DONT_ACCEPT=${DONT_ACCEPT:=false}
|
DONT_ACCEPT=${DONT_ACCEPT:=false}
|
||||||
|
|
||||||
@@ -39,6 +40,13 @@ die_with_usage() {
|
|||||||
" ${SELF} --abort"
|
" ${SELF} --abort"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify_gitlab_cli() {
|
||||||
|
which gitlab >/dev/null 2>&1 || \
|
||||||
|
die "You need to have gitlab cli installed and configured: "\
|
||||||
|
"" \
|
||||||
|
"$ gem install --user-install gitlab"
|
||||||
|
}
|
||||||
|
|
||||||
die_with_continue_instructions() {
|
die_with_continue_instructions() {
|
||||||
die "" \
|
die "" \
|
||||||
"Replay interrupted. Conflicts need to be fixed manually." \
|
"Replay interrupted. Conflicts need to be fixed manually." \
|
||||||
@@ -54,7 +62,7 @@ die_before_push() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
die_if_wrong_dir() {
|
die_if_wrong_dir() {
|
||||||
if [[ ! -d "$WORKDIR" ]]; then
|
if [[ ! -d ".git" ]]; then
|
||||||
die "You need to run this command from the toplevel of the working tree."
|
die "You need to run this command from the toplevel of the working tree."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -82,21 +90,6 @@ die_if_local_behind_target() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_workdir() {
|
|
||||||
DOTGIT="$(git rev-parse --show-toplevel)/.git"
|
|
||||||
if [[ -f "${WORKDIR}" ]]; then
|
|
||||||
sed -n 's/^gitdir: //p' "${DOTGIT}"
|
|
||||||
fi
|
|
||||||
echo "${DOTGIT}"
|
|
||||||
}
|
|
||||||
|
|
||||||
verify_gitlab_cli() {
|
|
||||||
which gitlab >/dev/null 2>&1 || \
|
|
||||||
die "You need to have gitlab cli installed and configured: "\
|
|
||||||
"" \
|
|
||||||
"$ gem install --user-install gitlab"
|
|
||||||
}
|
|
||||||
|
|
||||||
branch_exists() {
|
branch_exists() {
|
||||||
ESCAPED_BRANCH_NAME=${1//\//\\\/}
|
ESCAPED_BRANCH_NAME=${1//\//\\\/}
|
||||||
BRANCH_REGEX="/^(remotes\/)?${ESCAPED_BRANCH_NAME}$/"
|
BRANCH_REGEX="/^(remotes\/)?${ESCAPED_BRANCH_NAME}$/"
|
||||||
@@ -182,26 +175,18 @@ resume() {
|
|||||||
die_before_push
|
die_before_push
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git push ${TARGET_REMOTE} -u ${REPLAY_BRANCH}:${REPLAY_BRANCH}
|
if [[ "$DONT_ACCEPT" = "true" ]]; then
|
||||||
|
AUTOMERGE=""
|
||||||
REPLAY_COMMIT_TITLE="$(git show --format="%b" "${SOURCE_COMMIT}" 2>&1 | head -1)"
|
else
|
||||||
|
AUTO_MERGE="-o merge_request.merge_when_pipeline_succeeds"
|
||||||
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
|
fi
|
||||||
|
|
||||||
REPLAY_HASH=$(git show-ref --hash --heads "${REPLAY_BRANCH}")
|
git push -u ${TARGET_REMOTE} \
|
||||||
|
-o merge_request.create \
|
||||||
# gitlab accept_merge_request ${GITLAB_PROJECT_ID} ${MERGE_REQUEST_ID} "{should_remove_source_branch: true, merge_when_pipeline_succeeds: true, sha: '$REPLAY_HASH'}"
|
-o merge_request.remove_source_branch \
|
||||||
|
-o "merge_request.target=${TARGET_BRANCH}" \
|
||||||
echo "================================================================================"
|
${AUTO_MERGE} \
|
||||||
echo "=== Your new MR !${MERGE_REQUEST_ID} has been created"
|
"${REPLAY_BRANCH}:${REPLAY_BRANCH}"
|
||||||
echo "=== ${MERGE_REQUEST_BASE_URI}${MERGE_REQUEST_ID} ==="
|
|
||||||
echo "================================================================================"
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
exit 0
|
exit 0
|
||||||
@@ -218,7 +203,7 @@ cleanup() {
|
|||||||
rm -f "${STATE_FILE}"
|
rm -f "${STATE_FILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
STATE_FILE="$(get_workdir)/REPLAY_MERGE"
|
cd $(git rev-parse --show-toplevel)
|
||||||
|
|
||||||
next_action="go"
|
next_action="go"
|
||||||
while [[ $# -ge 1 ]]; do
|
while [[ $# -ge 1 ]]; do
|
||||||
|
Reference in New Issue
Block a user