No non-interactive way to select a stack when the branch belongs to several (e.g. the trunk)
- 主要語言
- Go
- 星號
- 1.5k
- 分支
- 70
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 7
描述
## Summary
When the current branch belongs to more than one stack — most commonly the trunk, which is the base of every stack in the repo — `gh stack view` fails and offers no non-interactive way out:
```
$ gh stack view --short
✗ branch "main" belongs to multiple stacks; use an interactive terminal to select one
```
There is no `--stack` flag. Combined with `gh stack view` silently discarding positional arguments (#414), there is currently **no way at all** to view a specific stack non-interactively.
## Why this matters
Two stacks off a shared trunk is the normal state for anyone working on more than one change at a time, not an edge case — and `main` is in that position permanently, so any script or agent that starts from the default branch hits this immediately.
"Use an interactive terminal" is not available in CI, in a shell script, or to an automated agent. The only workaround is to `gh stack checkout ` first purely to move onto a branch in the desired stack, which mutates the working tree just to perform a read.
## Reproduction
```bash
# create two stacks that both base off main
git switch main
gh stack view --short # -> "belongs to multiple stacks; use an interactive terminal"
```
Public repo with two stacks off a shared `main`: https://github.com/xn/gh-stack-repro
## Expected
A `--stack ` flag on `view` (and anywhere else this ambiguity can arise), so the stack can be named explicitly without changing the checked-out branch.
## Environment
- `gh` 2.97.0
- `gh-stack` v0.1.0
- git 2.50.1
- macOS 26.4.1, darwin/arm64
貢獻指南
研究方向
從 `gh stack view` 入口開始,追蹤它如何處理多個 stack、互動式選擇以及被捨棄的位置引數;將其與現有的 `gh stack checkout ` 選擇行為進行比較。完成標準是:`gh stack view --stack ` 可以從共用分支中選擇一個 stack,同時不變更已簽出的分支,包括已重現的 `main` 情境。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- go
- 領域
- cli
- Issue 類型
- 功能
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 64/100