[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
This commit is contained in:
parent
1d56e0371e
commit
99d197b309
1 changed files with 6 additions and 2 deletions
8
.github/scripts/pr-backport.sh
vendored
8
.github/scripts/pr-backport.sh
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
TARGET_REMOTE=upstream
|
TARGET_REMOTE=upstream
|
||||||
KEYCLOAK_REPO=https://github.com/keycloak/keycloak
|
KEYCLOAK_REPO=https://github.com/keycloak/keycloak
|
||||||
|
WORK_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
PR=$1
|
PR=$1
|
||||||
TARGET=$2
|
TARGET=$2
|
||||||
|
@ -44,7 +45,7 @@ git fetch $TARGET_REMOTE
|
||||||
PR_STATE=$(gh pr view $PR --json state 2>/dev/null | jq -r .state)
|
PR_STATE=$(gh pr view $PR --json state 2>/dev/null | jq -r .state)
|
||||||
|
|
||||||
if [ "$PR_STATE" == "" ]; then
|
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
|
elif [ "$PR_STATE" != "MERGED" ]; then
|
||||||
error "PR #$PR not merged yet. Only merged PRs can be backported."
|
error "PR #$PR not merged yet. Only merged PRs can be backported."
|
||||||
fi
|
fi
|
||||||
|
@ -78,10 +79,13 @@ echo_header "Checkout '$TARGET_REMOTE/$TARGET_BRANCH' to '$PR_BRANCH'"
|
||||||
git checkout $TARGET_REMOTE/$TARGET_BRANCH -B $PR_BRANCH
|
git checkout $TARGET_REMOTE/$TARGET_BRANCH -B $PR_BRANCH
|
||||||
|
|
||||||
echo_header "Cherry-pick $MERGE_COMMIT"
|
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"
|
echo_header "Push '$PR_BRANCH' to 'origin' remote"
|
||||||
git push origin $PR_BRANCH:$PR_BRANCH --set-upstream
|
git push origin $PR_BRANCH:$PR_BRANCH --set-upstream
|
||||||
|
|
||||||
echo_header "Opening web browser to create pull request"
|
echo_header "Opening web browser to create pull request"
|
||||||
gh pr create -B $TARGET_BRANCH -f -w
|
gh pr create -B $TARGET_BRANCH -f -w
|
||||||
|
|
||||||
|
echo_header "Checkout to $WORK_BRANCH branch"
|
||||||
|
git checkout $WORK_BRANCH
|
||||||
|
|
Loading…
Reference in a new issue