Repository navigation
fix(github): Check for a stack before merging the base on conflicts - #2598
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 3, 2026
BYK
added a commit
that referenced
this pull request
Nov 3, 2026
When Junior opens a PR on top of another PR's branch, the PRs form a plain base-branch chain. GitHub does not know they are a stack, so it cannot rebase them or merge them as one group. #2597 and #2598 taught the merge and conflict steps to use `gh stack` when a stack exists, but Junior never created one. `github_createPullRequest` now links the new PR into a native GitHub stack ([docs](https://docs.github.com/en/pull-requests/reference/stacked-pull-requests)). - Skip when the base is the repo's default branch or the head repo is a fork. Normal PRs get no extra calls. - Walk down the base branches through open PRs (up to 10 levels) to find the chain. - If the parent PR is the top of a stack, add the new PR to that stack (`POST /stacks/{n}/add`). If the parent is in the middle of a stack, skip. Otherwise create a stack from the bottom PR to the top (`POST /stacks`). - The tool result returns `stack: { number, pullRequests }` when the link succeeds. Stacking is optional, like requester assignment. A rejected call logs `github.pull_request.stack_after_create.rejected`, and an exception logs `github.pull_request.stack_after_create.failed`. PR creation never fails because of stacking. Known gaps: - A replayed create call (the PR already exists) does not stack. - Junior watches only the PRs it opens. If a person owns the bottom PR, Junior does not get its merge event. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3Ae089395b988fbf2d85490e6b --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3Ae089395b988fbf2d85490e6b/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up to #2597 that fixes a Bugbot finding. That PR merged before the fix landed.
In the post-push check in
workflow.md, theCONFLICTINGstep said to merge the base without exceptions. The stacked-PR exception came after it as a separate step. An agent could follow the first step and add a merge commit to a stacked PR. A stack can't merge with that commit in its history. Now the step checks for a stack first, so stacked PRs restack and other PRs still merge the base.--
View Session in Sentry