From 99d197b309adac3bd2bac9c8553a37d3b92801f8 Mon Sep 17 00:00:00 2001 From: Lukas Hanusovsky <61745358+lhanusov@users.noreply.github.com> Date: Fri, 8 Dec 2023 17:33:40 +0100 Subject: [PATCH] [enhancement] pr-backport.sh - make it more understandable when using gh and git (#25411) [enhancement] pr-backport.sh improve usability * Make it more understandable when using gh and git * Update pr-backport.sh - WORK_BRANCH param * Update pr-backport.sh - cherry-pick -x Signed-off-by: Lukas Hanusovsky lhanusov@redhat.com --- .github/scripts/pr-backport.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/scripts/pr-backport.sh b/.github/scripts/pr-backport.sh index 90caf18f2c7..4dcf5608c0f 100755 --- a/.github/scripts/pr-backport.sh +++ b/.github/scripts/pr-backport.sh @@ -2,6 +2,7 @@ TARGET_REMOTE=upstream KEYCLOAK_REPO=https://github.com/keycloak/keycloak +WORK_BRANCH=$(git rev-parse --abbrev-ref HEAD) PR=$1 TARGET=$2 @@ -44,7 +45,7 @@ git fetch $TARGET_REMOTE PR_STATE=$(gh pr view $PR --json state 2>/dev/null | jq -r .state) if [ "$PR_STATE" == "" ]; then - error "PR #$PR not found. Make sure the PR exists, and that it's been merged." + error "PR #$PR not found. Make sure the PR exists, and that it's been merged, and your gh repo is set to keycloak/keycloak" elif [ "$PR_STATE" != "MERGED" ]; then error "PR #$PR not merged yet. Only merged PRs can be backported." fi @@ -78,10 +79,13 @@ echo_header "Checkout '$TARGET_REMOTE/$TARGET_BRANCH' to '$PR_BRANCH'" git checkout $TARGET_REMOTE/$TARGET_BRANCH -B $PR_BRANCH echo_header "Cherry-pick $MERGE_COMMIT" -git cherry-pick $MERGE_COMMIT +git cherry-pick -x $MERGE_COMMIT echo_header "Push '$PR_BRANCH' to 'origin' remote" git push origin $PR_BRANCH:$PR_BRANCH --set-upstream echo_header "Opening web browser to create pull request" gh pr create -B $TARGET_BRANCH -f -w + +echo_header "Checkout to $WORK_BRANCH branch" +git checkout $WORK_BRANCH