From cabf9ab27ad03d4629c3a88b8f780f3f823f5331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 16 May 2018 08:12:23 +0200 Subject: [PATCH 1/2] Update git-replay-merge script to use gitlab CLI to push merge request automatically --- util/git-replay-merge.sh | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/util/git-replay-merge.sh b/util/git-replay-merge.sh index ec8180c850..81ee5c4eee 100644 --- a/util/git-replay-merge.sh +++ b/util/git-replay-merge.sh @@ -147,34 +147,15 @@ resume() { die_with_continue_instructions fi fi - # Announce the plan. - echo "Attempting to merge ${REPLAY_BRANCH} into ${TARGET_BRANCH}..." - # Check if a local branch with the same name as the target branch - # exists. If it does not, switch to a new local branch with the same - # name as the target branch. Otherwise, ensure the local branch is not - # behind the target branch at the target remote, then switch to it. - if ! branch_exists "${TARGET_BRANCH}"; then - git checkout -t -b "${TARGET_BRANCH}" "${TARGET_REF}" >/dev/null - else - die_if_local_behind_target - git checkout "${TARGET_BRANCH}" &>/dev/null - fi - # Use the original commit message with a modified subject line. - COMMIT_MSG="$( - git log --max-count=1 --format="%B" "${SOURCE_COMMIT}" | - sed "1s/.*/Merge branch '${REPLAY_BRANCH}' into '${TARGET_BRANCH}'/;" - )" - # Merge the replay branch into the local target branch. - git merge --no-ff -m "${COMMIT_MSG}" "${REPLAY_BRANCH}" - cat <<-EOF - Replayed ${SOURCE_BRANCH} onto ${TARGET_BRANCH}. - To push the replay, use: + git push ${TARGET_REMOTE} -u ${REPLAY_BRANCH} - git push ${TARGET_REMOTE} ${TARGET_BRANCH}:${TARGET_BRANCH} + REPLAY_COMMIT_TITLE="$(git show --format="%b" "${SOURCE_COMMIT}" 2>&1 | head -1)" - EOF + gitlab create_merge_request 1 "${REPLAY_COMMIT_TITLE}" "{source_branch: '${REPLAY_BRANCH}', target_branch: '${TARGET_BRANCH}'}" + cleanup + exit 0 } cleanup() { @@ -184,7 +165,6 @@ cleanup() { git merge --abort git cherry-pick --abort git checkout "${CHECKED_OUT_BRANCH}" - git branch -D "${REPLAY_BRANCH}" } &>/dev/null || true rm -f "${STATE_FILE}" } From 3a643ee5b8799a5a1f0cc4caf6e231e438a60c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 16 May 2018 09:20:58 +0200 Subject: [PATCH 2/2] Add *.rej and *.orig to the global .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5359c1eb3e..b91ecf0488 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ libtool /isc-config.sh /configure.lineno autom4te.cache/ +*.rej +*.orig *.o *.lo *.so