Skip to content

Commit

Permalink
feat(tooling): Add support for multiple commits PR backport (#7902)
Browse files Browse the repository at this point in the history
Co-authored-by: Bruce Bujon <[email protected]>
  • Loading branch information
ygree and PerfectSlayer authored Nov 7, 2024
1 parent 7eed45f commit d14e296
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tooling/backport-pr-to-patch-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d14e296

Please sign in to comment.