Partial merge leaves stale stack base and Rebase stack replays merged commits

未关闭
#485 0 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
git, github, go
领域
api, cli

调研方向

首先跟踪 merge-queue admission 和 Rebase stack 路径,重点关注部分合并后 Stack 对象的 base SHA 如何更新。复现包含八个 PR 的场景,并检查 Rebase stack 前后报告的 base ref 和 SHA。完成的标准是:剩余的 stack 以当前 main 提交为目标,接纳经过验证的后缀,并且不会重新播放已合并的提交。

由索引模型根据 Issue 内容生成。

描述

Reproduction

  1. Create a stack with a merge queue on main.
  2. Merge a bottom prefix of the stack, leaving eight pull requests open.
  3. Rebase the eight remaining branches locally onto the current main, then force-push them as one atomic ref update.
  4. Verify that the lowest open branch is one commit ahead of main, zero commits behind, and that every higher branch contains the branch below it.
  5. Verify that every open pull request is approved and has passing required checks.
  6. Enqueue the remaining stack from its top pull request.

All eight pull requests entered the queue within one second. Eighteen seconds later, the lowest open pull request was removed with:

github-merge-queue removed this pull request from the merge queue due to invalid changes in the merge commit

Every higher pull request was then removed because an earlier pull request in the stack was removed. No merge_group workflow was created.

The stack merge box reported that the stack was out of date with main. The pull request API reported stack.base.ref = main, but stack.base.sha still identified the last layer of the already-merged prefix rather than the current main commit.

  1. Click Rebase stack in the GitHub UI.

The UI reported that all eight branches were rebased and that the stack had a linear history. The actual lowest branch changed from one commit ahead and zero behind to 16 commits ahead and 15 behind. Commits already present on main reappeared in the pull request.

Expected

After a partial stack merge, GitHub updates the remaining stack's base to the current main commit and retargets the lowest open pull request to main, as described in Merging stacked pull requests.

A locally verified linear suffix based on current main should enter the merge queue. Rebase stack must use the current base commit and must not replay commits that already landed.

Actual

The remaining stack retains a stale base SHA after the partial merge. Merge-queue admission rejects a correct branch graph before creating a merge group. Rebase stack then rewrites the branches against the stale anchor and reintroduces already-merged commits.

Recovery requires restoring every branch ref, removing the stale Stack object, retargeting the lowest open pull request to main, and linking the same pull requests into a new stack.

Environment

  • GitHub Stacked Pull Requests public preview.
  • GitHub merge queue.
  • Original stack: 26 pull requests, with 18 merged and eight open.
  • All open pull requests approved and required checks passing.
  • gh stack v0.1.0.
  • gh 2.96.0.
  • git 2.50.1.
  • macOS arm64.

Related

  • #174 concerns approval invalidation after a partial merge. Approvals remained valid in this reproduction.
  • #444 concerns a pull request being closed at a merge-group boundary. The remaining pull requests stayed open in this reproduction, but the stack base remained stale.
主要语言
Go
星标
1.5k
派生
73
平均合并
1 天 8 小时
30 天内合并 PR
7

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/gh-stack 的其他 Issue

查看 github/gh-stack 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。