Skip to content

Commit

Permalink
fix(cherry-pick): respect squash-merges and rebase-merges
Browse files Browse the repository at this point in the history
Detect if the merge method was either "Squash and Merge" or
"Rebase and Merge" by looking at the `merge_commit_sha` field
that gets populated when the PR is merged. When the `merge_commit_sha`
and the parent of this commit have an association to the pullrequest
we can assume that this was "rebased" as the squash method would only
produce one commit (the squashed one).
When the PR was squashed, we can use the `merge_commit_sha` to create
a cherry-pick.
When the PR was reased, we can fall back to the existing method and
use the commits associated with the PR before merging.

Signed-off-by: Joshua Schmid <[email protected]>
  • Loading branch information
jschmid1 committed Nov 23, 2023
1 parent 0ddde04 commit a27f20f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cherry-picks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(fromJSON('["MEMBER", "COLLABORATOR", "OWNER"]'), github.event.comment.author_association) &&
contains(github.event.comment.body, '/cherry-pick')
startsWith(github.event.comment.body, '/cherry-pick')
)
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.CHERRY_PICK_TOKEN }}
- name: Create backport pull requests
uses: jschmid1/cross-repo-cherrypick-action@2366f50fd85e8966aa024a4dd6fbf70e7019d7e1
uses: jschmid1/cross-repo-cherrypick-action@5976eb414878ce8a412e0dfebf0068d1a41ee928
with:
token: ${{ secrets.CHERRY_PICK_TOKEN }}
pull_title: '[cherry-pick -> ${target_branch}] ${pull_title}'
Expand Down

0 comments on commit a27f20f

Please sign in to comment.