You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ac6079a
Browse filesBrowse the repository at this point in the historyBrowse files
Update docs and agent instructions for the new API
- cli.md: document checkout/unstack by stack number and drop the
"PATs are not supported" note (any gh-authenticated user can now run
stack operations).
- quick-start.md: drop the PAT-not-supported note.
- AGENTS.md / copilot-instructions.md: ClientOps is now 13 methods over
the public Stacks REST API; remove the TokenForHostFn test hook; note
the stack file's id/number identity.
- SKILL.md: add checkout/unstack-by-stack-number quick references.
Copilot-Session: 03673c26-a245-42da-93ed-dfcebc92a740
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ No Makefile, no code generation, no external linter config. Standard Go toolchai
17
17
18
18
-`cmd/`: One Cobra command per file. Each exports `<Name>Cmd(cfg *config.Config)` with logic in `run<Name>()`.
19
19
-`internal/git/`: `Ops` interface (52 methods) wrapping git CLI. `MockOps` for tests. Package-level functions delegate to swappable `ops` variable.
20
-
-`internal/github/`: `ClientOps` interface (11 methods) for GitHub API. `MockClient` for tests.
20
+
-`internal/github/`: `ClientOps` interface (13 methods) for GitHub API. `MockClient` for tests. Stack operations use the public Stacks REST API (`/repos/{owner}/{repo}/stacks`).
21
21
-`internal/config/`: `Config` struct passed to all commands. Holds I/O, colors, and test hooks (`SelectFn`, `ConfirmFn`, `InputFn`, `GitHubClientOverride`).
22
22
-`internal/stack/`: Stack file (`.git/gh-stack`, JSON) management with file locking.
schema.json # JSON Schema for the stack file format
@@ -109,13 +109,14 @@ if errors.As(err, &exitErr) { ... }
109
109
### Key interfaces
110
110
111
111
-**`git.Ops`** (`internal/git/gitops.go`): 52 methods wrapping git CLI calls. The production implementation uses `cli/go-gh`'s `client.Command()` via `run()` and `runSilent()` helpers. Package-level functions (e.g., `git.CurrentBranch()`) delegate to a swappable package-level `ops` variable.
112
-
-**`github.ClientOps`** (`internal/github/client_interface.go`): 11 methods for GitHub API (PRs, stacks). Injected via `cfg.GitHubClientOverride` in tests.
113
-
-**`config.Config`** (`internal/config/config.go`): Central configuration passed to all commands. Holds I/O streams, color functions, and test hook fields (`SelectFn`, `ConfirmFn`, `InputFn`, `TokenForHostFn`, `RepoOverride`).
112
+
-**`github.ClientOps`** (`internal/github/client_interface.go`): 13 methods for GitHub API (PRs, stacks). Stack operations use the public Stacks REST API (`/repos/{owner}/{repo}/stacks`): `ListStacks`, `FindStackForPR`, `GetStack`, `CreateStack`, `AddToStack` (delta append), `Unstack`. Injected via `cfg.GitHubClientOverride` in tests.
113
+
-**`config.Config`** (`internal/config/config.go`): Central configuration passed to all commands. Holds I/O streams, color functions, and test hook fields (`SelectFn`, `ConfirmFn`, `InputFn`, `RepoOverride`).
114
114
115
115
### Stack file
116
116
117
117
-**Location:**`.git/gh-stack` (JSON format, schema version 1).
118
118
-**Schema:**`internal/stack/schema.json`.
119
+
-**Identity:** each stack stores GitHub's global `id` (string) and repo-scoped `number` (int, shown in the GitHub UI and used as the primary way to reference a stack, e.g. `gh stack checkout <number>`). `number` may be `0` for stack files created before it was tracked; it is backfilled from the API on the next stack operation.
119
120
-**Locking:** Exclusive file lock at `.git/gh-stack.lock` with 5-second timeout. Errors surface as `LockError`.
120
121
-**Staleness:** Concurrent modifications detected via `StaleError`.
When a PR number or URL is provided (e.g., `123` or `https://github.com/owner/repo/pull/123`), the command fetches the stack on GitHub, pulls the branches, and sets up the stack locally. If the stack already exists locally and matches, it switches to the branch. If the local and remote stacks have different compositions, you'll be prompted to resolve the conflict.
144
+
A bare number is interpreted first as a stack or PR number (repo-scoped identifiers shown in the GitHub UI). If nothing matches the number, it is tried as a branch name.
145
+
146
+
When a remote stack is referenced, the command fetches the stack on GitHub, pulls the branches, and sets up the stack locally. If the stack already exists locally and matches, it switches to the branch. If the local and remote stacks have different compositions, you'll be prompted to resolve the conflict.
145
147
146
148
When a branch name is provided, the command resolves it against locally tracked stacks only.
147
149
@@ -150,6 +152,9 @@ When run without arguments in an interactive terminal, shows a menu of all local
150
152
**Examples:**
151
153
152
154
```sh
155
+
# Check out a stack by its stack number
156
+
gh stack checkout 7
157
+
153
158
# Check out a stack by PR number
154
159
gh stack checkout 42
155
160
@@ -229,28 +234,31 @@ gh stack modify --abort
229
234
230
235
### `gh stack unstack`
231
236
232
-
Remove a stack from local tracking and delete it on GitHub. Also available as `gh stack delete`.
237
+
Remove a stack from local tracking and unstack it on GitHub. Also available as `gh stack delete`.
233
238
234
239
```sh
235
-
gh stack unstack [flags]
240
+
gh stack unstack [<stack-number>] [flags]
236
241
```
237
242
238
-
You must have a branch from the stack checked out locally. The command targets the active stack — the one that contains the currently checked out branch.
243
+
With no argument, the command targets the active stack — the one that contains the currently checked out branch. Provide a stack number (the identifier shown in the github.com stack UI) to target a specific locally tracked stack instead.
239
244
240
-
Deletes the stack on GitHub first, if it exists, then removes it from local tracking. If the remote deletion fails, the local state is left untouched so you can retry. Use `--local` to skip the remote deletion and only remove local tracking.
245
+
PRs that are merged, merging, or queued for merge cannot be removed from a stack on GitHub and are left part of the stack. When every pull request is removed, the stack is dissolved and local tracking is removed; when some pull requests remain stacked, local tracking is kept. Use `--local` to skip the remote operation and only remove local tracking.
241
246
242
247
This is useful when you need to restructure a stack — remove a branch, insert a branch, reorder branches, rename branches, or make other large changes. After unstacking, use `gh stack init` to re-create the stack with the desired structure — existing branches are adopted automatically.
243
248
244
249
| Flag | Description |
245
250
|------|-------------|
246
-
|`--local`| Only delete the stack locally (keep it on GitHub) |
251
+
|`--local`| Only remove the stack locally (keep it on GitHub) |
247
252
248
253
**Examples:**
249
254
250
255
```sh
251
-
#Delete the stack on GitHub and remove local tracking
256
+
#Unstack the current stack on GitHub and remove local tracking
252
257
gh stack unstack
253
258
259
+
# Unstack a specific stack by its stack number
260
+
gh stack unstack 7
261
+
254
262
# Only remove local tracking
255
263
gh stack unstack --local
256
264
```
@@ -317,7 +325,7 @@ Performs a synchronization of the entire stack:
317
325
318
326
A clean remote-ahead update (PRs added on top of your local stack) is pulled down automatically without prompting, so `sync` is safe to run in automation. Sync only prompts when the stacks have truly diverged.
319
327
320
-
#### Diverged stacks
328
+
**Diverged stacks**
321
329
322
330
When neither stack is a clean prefix of the other — for example, you added a branch locally while separate PRs were added to the same stack on GitHub — sync cannot merge the two automatically. In an interactive terminal it offers three choices:
0 commit comments