[Bug]: After the merge queue merges only the bottom of a stack, the lowest open PR keeps the merged PR's branch as its base
Describe the bug
The merge queue merged the bottom four PRs of a stack and removed the fifth after its checks failed.
The fifth PR, now the lowest open one, was neither retargeted to the trunk nor rebased. It still
targets the fourth PR's head branch, still carries the fourth PR's original commits, and conflicts
with the trunk. Enqueueing it again fails with merge_conflict.
Unlike #581, PR 5's branch contains PR 4's final head commit.
Affected command
None: the merge queue on github.com (the stack was enqueued from the web UI)
gh-stack version
gh stack version 0.2.0 at the time of the merge (now 0.3.0)
GitHub CLI version
gh version 2.102.1 (2026-10-20)
Operating system
macOS 26.7.1
Shell
fish
Steps to reproduce
- Repository: merge queue required on
main, squash merges, Automatically delete head branches off. - A stack of 10 PRs on
main. PR 5's branch contains PR 4's head commit. - From the web UI, enqueue PRs 1–7 of the stack together.
- PR 5's merge group, built on PR 4's squash commit, fails a required check (one flaky test).
- The queue removes PR 5 (
failed_checks) and merges PRs 1–4. PRs 6 and 7 leave the queue unmerged. - Inspect PR 5, then enqueue it again.
Expected behavior
PR 5 becomes the bottom of the stack on main: it is retargeted to main and rebased onto
the squash commits of PRs 1–4, as happens after a partial merge with Merge stack in the web UI (see #585).
Actual behavior
| PR 5 after PRs 1–4 merged | Expected | Actual |
|---|---|---|
| Base branch | main |
PR 4's head branch |
| Base-change event in timeline | automatic_base_change_succeeded |
none |
| Head branch | rebased onto PR 4's squash commit | unchanged, still holds PRs 1–4's original commits |
Trial merge into main |
clean | conflicts in 3 files |
| Enqueued again | merge group created | removed after 16 s, reason merge_conflict |
Replaying only PR 5's own commits onto main applies cleanly.
Terminal output
Merge-queue events on PR 5 (GraphQL timelineItems):
2026-10-27T19:25:09Z AddedToMergeQueueEvent
2026-10-27T19:44:20Z RemovedFromMergeQueueEvent reason: failed_checks
2026-10-27T20:04:17Z AddedToMergeQueueEvent
2026-10-27T20:04:33Z RemovedFromMergeQueueEvent reason: merge_conflict
PRs 1–4: merged at 2026-10-27T19:44:20Z.