github / github/gh-stack

No non-interactive way to select a stack when the branch belongs to several (e.g. the trunk)

Offen
#415 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
feature request topic: cli - view
Vorherrschende Sprache
Go
Sterne
1.5k
Forks
70
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
7

Beschreibung

## 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne am Einstiegspunkt `gh stack view` und verfolge, wie mehrere Stacks, die interaktive Auswahl und das verworfene Positionsargument verarbeitet werden; vergleiche dies mit dem bestehenden Auswahlverhalten von `gh stack checkout `. Als erledigt gilt, wenn `gh stack view --stack ` einen Stack aus einem gemeinsamen Branch auswählen kann, ohne den ausgecheckten Branch zu ändern, einschließlich des reproduzierten `main`-Szenarios.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
go
Bereich
cli
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
64/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.