Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

One-PR stack: submit reports success, but merge says the stack was not submitted

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

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
cli

调研方向

从 cmd/submit.go 开始,阅读 syncStack 及其调用方,然后对比 cmd/merge.go 中的 remote-stack 检查。使用 issue 中的命令重现 one-PR 流程;完成的标准是 submit 准确报告缺失的 remote-stack,且 merge 给出可用的结果或下一条命令,而不是要求用户重复一次已成功的提交。

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

描述

bug topic: cli - submit

Summary

A local stack can contain one branch and one pull request. gh stack submit reports success for this stack:

✓ Pushed and synced 1 branches

However, GitHub does not create a remote stack object. A remote stack requires at least two pull requests.

gh stack merge then rejects the local stack:

✗ this stack has not been submitted to GitHub yet; run `gh stack submit` first

A second gh stack submit does not fix the problem. It reports success again.

Reproduction

  1. Create a branch from the trunk branch.
  2. Commit a change on the new branch.
  3. Initialize a local stack that contains only the new branch.
  4. Run gh stack submit and create the pull request.
  5. Run gh stack submit again.
  6. Run gh stack merge --squash.

Example output:

$ gh stack submit
Checking stack state...
Pushing to origin...
PR #30 for close-clinkr-cli-entry-point is up to date
✓ Pushed and synced 1 branches

$ gh stack sync
✓ Fetched latest main from origin
✓ Trunk main is already up to date

Pushing 1 branch to origin...
✓ Pushed 1 branches

Syncing PRs ...
✓ PR #30 (close-clinkr-cli-entry-point) — Open

✓ Branches synced
  Stacked on main (69c442c)

$ gh stack merge --squash
✗ this stack has not been submitted to GitHub yet; run `gh stack submit` first

The pull request exists and is open. In this reproduction, GitHub also reported the pull request as mergeable and clean.

Expected behavior

The commands should not give conflicting results.

gh stack submit should state that it published a regular pull request but did not create a remote stack object. Alternatively, it should explain that a remote stack requires at least two pull requests.

gh stack merge should handle a local stack with one pull request. It can merge the pull request directly, or it can show an actionable command such as gh pr merge.

Actual behavior

gh stack submit reports that it pushed and synchronized the one-branch stack. It exits successfully.

gh stack merge reports that the same stack was not submitted. It tells the user to repeat the command that already reported success.

Source context

The behavior is also present on the current github/gh-stack main branch at commit ab00aa4a3f2dddc51aa65849c68b391a1b079311.

In cmd/submit.go, syncStack returns false when the stack has fewer than two pull requests:

// The API requires at least 2 PRs to form a stack.
if len(prNumbers) < 2 {
    return false
}

The caller does not use this result:

if stacksAvailable {
    syncStack(cfg, client, s)
    clearPendingModifyState(cfg, gitDir)
}

The command then prints the success message:

cfg.Successf("Pushed and synced %d branches", len(s.ActiveBranches()))

In cmd/merge.go, the merge command requires a remote stack ID or number:

if s.ID == "" && s.Number == 0 {
    cfg.Errorf("this stack has not been submitted to GitHub yet; run `gh stack submit` first")
    return nil, ErrNotInStack
}

Thus, the submit command knows that it did not create a remote stack object. However, it discards that result and reports success.

Environment

gh stack version 0.1.0
Darwin 25.6.0 arm64

Deviations: none.

主要语言
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 摘要。