diff --git a/.github/scripts/pr-backport.sh b/.github/scripts/pr-backport.sh index 90caf18f2c..4dcf5608c0 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