One-PR stack: submit reports success, but merge says the stack was not submitted
- 主要語言
- Go
- 星號
- 1.5k
- 分支
- 70
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 7
描述
## Summary
A local stack can contain one branch and one pull request. `gh stack submit` reports success for this stack:
```text
✓ 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:
```text
✗ 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:
```text
$ 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:
```go
// The API requires at least 2 PRs to form a stack.
if len(prNumbers) < 2 {
return false
}
```
The caller does not use this result:
```go
if stacksAvailable {
syncStack(cfg, client, s)
clearPendingModifyState(cfg, gitDir)
}
```
The command then prints the success message:
```go
cfg.Successf("Pushed and synced %d branches", len(s.ActiveBranches()))
```
In `cmd/merge.go`, the merge command requires a remote stack ID or number:
```go
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
```text
gh stack version 0.1.0
Darwin 25.6.0 arm64
```
---
Deviations: none.
貢獻指南
研究方向
從 cmd/submit.go 開始閱讀 syncStack 及其呼叫方,然後比較 cmd/merge.go 中的 remote-stack 檢查。使用 issue 中的指令重現 one-PR 流程;完成的標準是 submit 準確回報缺少的 remote-stack,且 merge 提供可用的結果或下一個指令,而不是要求使用者重複一次已成功的提交。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- go
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 76/100