github / github/gh-stack

`gh stack view` silently ignores positional arguments, including a valid different stack number

Đang mở
#414 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug topic: cli - view
Ngôn ngữ chính
Go
Star
1.5k
Fork
70
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
7

Mô tả

## Summary

`gh stack view` accepts no positional argument, but supplying one is silently discarded instead of rejected. The harmful case is passing a **valid stack number that isn't the current one** — you get a different stack's contents, with that stack's number in the header, and no indication your argument was ignored.

On a branch belonging to stack #6, asking for stack #3 (which exists):

```
$ gh stack view --short 3
Stack #6 <-- rendered #6, not the #3 that was requested
├ stack-b-two ○ #5
» stack-b-one ○ #4 (current)
└ main

$ gh stack view --short garbage999
Stack #6 <-- also silently succeeds
├ stack-b-two ○ #5
» stack-b-one ○ #4 (current)
└ main
```

Exit status is 0 in both cases.

## Why this matters

The output carries a stack number in its header, so it reads as authoritative. Anyone comparing two stacks — or scripting against `view` — can act on the wrong one without any signal. It is also a natural mistake to make, because `gh stack checkout` *does* take a stack number, so the two commands look like they share a selector.

## Reproduction

In a repo with two stacks:

```bash
git switch
gh stack view --short # shows stack B
gh stack view --short garbage999 # shows stack B
```

Public repo with two stacks set up for this: https://github.com/xn/gh-stack-repro

## Expected

Either error with `unknown argument "3"` (the usual `gh` behaviour for unexpected positionals), or accept a stack selector here the way `gh stack checkout` does. The latter would also give a non-interactive escape hatch for the ambiguity in #415.

## Environment

- `gh` 2.97.0
- `gh-stack` v0.1.0
- git 2.50.1
- macOS 26.4.1, darwin/arm64

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start at the `gh stack view` command's argument parsing and reproduce the two commands from the issue, including their exit status and output. Check how `gh stack checkout` handles a stack number, then add coverage for valid and invalid positional arguments. Done means the command no longer silently ignores them: it should either reject them clearly or consistently support stack selection.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
58/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.