From 0ee9f1fca6f1a66268297ee126c9a1d2e716b242 Mon Sep 17 00:00:00 2001 From: Bruce Bujon Date: Wed, 6 Nov 2024 09:51:04 +0100 Subject: [PATCH] feat(tooling): Add support for multiple commits PR backport --- tooling/backport-pr-to-patch-release.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tooling/backport-pr-to-patch-release.sh b/tooling/backport-pr-to-patch-release.sh index d56aa5b4453..12b23b723ae 100755 --- a/tooling/backport-pr-to-patch-release.sh +++ b/tooling/backport-pr-to-patch-release.sh @@ -50,8 +50,8 @@ git fetch --quiet git show-ref --verify --quiet "refs/remotes/origin/$PATCH_RELEASE_BRANCH" 1>/dev/null 2>&1 || { echo "Branch $PATCH_RELEASE_BRANCH does not exist"; exit 1; } # Check PR exists echo "- Checking PR exists" -PR_COMMIT=$(gh pr view "$PR_NUMBER" --json commits --jq '.commits[].oid') -if [ -z "$PR_COMMIT" ]; then +PR_COMMITS=$(gh pr view "$PR_NUMBER" --json commits --jq '.commits[].oid') +if [ -z "$PR_COMMITS" ]; then echo "PR $PR_NUMBER does not exist" exit 1 fi @@ -68,8 +68,10 @@ git pull # Create a new branch for the backport BRANCH_NAME="$USER/backport-pr-$PR_NUMBER" git checkout -b "$BRANCH_NAME" -# Cherry-pick PR commit -git cherry-pick "$PR_COMMIT" +# Cherry-pick PR commits +for PR_COMMIT in $PR_COMMITS; do + git cherry-pick -x "$PR_COMMIT" +done # Push the branch git push -u origin "$BRANCH_NAME" --no-verify # Create a PR