Skip to content

switch command#51

Merged
skarim merged 5 commits into
skarim/simple-api-wrapperfrom
skarim/switch-branch
Apr 20, 2026
Merged

switch command#51
skarim merged 5 commits into
skarim/simple-api-wrapperfrom
skarim/switch-branch

Conversation

@skarim

@skarim skarim commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

Add gh stack switch command

Adds a new switch navigation command that shows an interactive picker for switching to any branch in the current stack. Branches are displayed top-to-bottom with their position number:

Select a branch in the stack to switch to
  5. frontend
  4. api-endpoints
  3. auth-layer
  2. db-schema
  1. config-setup

Copilot AI review requested due to automatic review settings April 17, 2026 08:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new gh stack switch CLI command that interactively lets users pick and check out another branch within the current stack.

Changes:

  • Introduces gh stack switch command implementation and wires it into the root command.
  • Adds test-only selection injection (Config.SelectFn) to allow deterministic interactive-selection tests.
  • Updates CLI reference docs and README to document the new command.
Show a summary per file
File Description
internal/config/config.go Adds SelectFn hook to simulate interactive selection in tests.
cmd/switch.go Implements the switch command with an interactive picker and checkout behavior.
cmd/root.go Registers the new switch command under gh stack.
cmd/switch_test.go Adds unit/integration-style tests for selection behavior, ordering, and error cases.
docs/src/content/docs/reference/cli.md Documents gh stack switch usage and example output.
README.md Adds switch to the command list and examples.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 6/6 changed files
  • Comments generated: 3

Comment thread cmd/switch.go
Comment thread cmd/switch.go
Comment thread cmd/switch.go Outdated
@skarim skarim force-pushed the skarim/switch-branch branch from 4db03c4 to c348c63 Compare April 17, 2026 08:24
@skarim skarim force-pushed the skarim/simple-api-wrapper branch 2 times, most recently from 32de12d to ced6b5e Compare April 17, 2026 12:30
@skarim skarim force-pushed the skarim/switch-branch branch 2 times, most recently from 5bbf9e0 to ccca492 Compare April 17, 2026 20:50
@skarim skarim force-pushed the skarim/simple-api-wrapper branch from ced6b5e to a2c7a18 Compare April 17, 2026 20:50
@skarim skarim force-pushed the skarim/switch-branch branch from ccca492 to f5055d4 Compare April 17, 2026 21:50
@skarim skarim force-pushed the skarim/simple-api-wrapper branch from a2c7a18 to 0386acd Compare April 17, 2026 21:50
@skarim skarim force-pushed the skarim/switch-branch branch from 1458516 to e86589d Compare April 18, 2026 00:14
@skarim skarim disabled auto-merge April 18, 2026 00:24
@skarim skarim disabled auto-merge April 18, 2026 02:14
@skarim skarim merged commit 6eda231 into main Apr 20, 2026
@skarim skarim deleted the skarim/switch-branch branch April 20, 2026 14:17
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
skarim added a commit that referenced this pull request Apr 20, 2026
* switch cmd to interactively switch to another branch in the stack

* add switch to docs

* addressing review comments

* bump skill file version

* default to current branch
ryanclark added a commit to ryanclark/gh-stack that referenced this pull request Jun 19, 2026
Ports the still-applicable upstream changes since the fork point, adapted
to this fork's standard-GitHub-API architecture (no private stack backend;
stack deps tracked via "Requires #N"). Each change was test-driven.

Bug fixes:
- github#56  guard GraphQL PR-number conversion against int32 overflow
- github#41  skip merged+deleted branches when rebasing (rev-parse error)
- github#42  same fix on the sync path
- github#43  --onto rebase for merged branches: backfill refs, pre-seed onto
       state, stale-base fallback via merge-base
- github#39  always anchor branch diffs on the merge-base (inflated diff counts)
- github#95  sync now cascades when the stack is stale even if trunk is current;
       rebase skips queued branches (IsSkipped)
- github#80  view --json resolves directly with typed exit codes (no prompt)
- github#49  (Part A) ignore stale merged/closed PRs for reused branch names
       (the backend ListStacks path is intentionally omitted)

Features (standard API only):
- github#108 trunk command       - github#51  switch command
- github#74  unstack -> active    - github#101 add adopts existing branch
- github#40  fast-forward branches behind their remote
- github#76  draft PRs by default + --open (adds MarkPRReadyForReview)
- github#77  seed PR body from repo template (keeps "Requires #N")
- github#94  sync --prune merged branches

Infra / cleanup:
- github#103/github#110 bump github.com/cli/cli/v2 to v2.93.0 (go get + tidy)
- github#89  remove placeholder `merge` command + docs
- fix stale `unstack [branch]` docs

Note: this commit is layered on in-progress local work (go-git ops,
PR/commit caching, discover command) that shares the same files, so the
two are committed together. Full suite green: build, vet, go test ./...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants