Skip to content

Commit d14e296

Browse files
ygreePerfectSlayer
andauthored
feat(tooling): Add support for multiple commits PR backport (#7902)
Co-authored-by: Bruce Bujon <[email protected]>
1 parent 7eed45f commit d14e296

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tooling/backport-pr-to-patch-release.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ git fetch --quiet
5050
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; }
5151
# Check PR exists
5252
echo "- Checking PR exists"
53-
PR_COMMIT=$(gh pr view "$PR_NUMBER" --json commits --jq '.commits[].oid')
54-
if [ -z "$PR_COMMIT" ]; then
53+
PR_COMMITS=$(gh pr view "$PR_NUMBER" --json commits --jq '.commits[].oid')
54+
if [ -z "$PR_COMMITS" ]; then
5555
echo "PR $PR_NUMBER does not exist"
5656
exit 1
5757
fi
@@ -68,8 +68,10 @@ git pull
6868
# Create a new branch for the backport
6969
BRANCH_NAME="$USER/backport-pr-$PR_NUMBER"
7070
git checkout -b "$BRANCH_NAME"
71-
# Cherry-pick PR commit
72-
git cherry-pick "$PR_COMMIT"
71+
# Cherry-pick PR commits
72+
for PR_COMMIT in $PR_COMMITS; do
73+
git cherry-pick -x "$PR_COMMIT"
74+
done
7375
# Push the branch
7476
git push -u origin "$BRANCH_NAME" --no-verify
7577
# Create a PR

0 commit comments

Comments
 (0)