link command for api-only operations#50
Open
skarim wants to merge 4 commits intoskarim/ignore-merged-prsfrom
Open
link command for api-only operations#50skarim wants to merge 4 commits intoskarim/ignore-merged-prsfrom
skarim wants to merge 4 commits intoskarim/ignore-merged-prsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new gh stack link command intended for “API-first” stacked PR operations—linking existing PRs and/or branches into a GitHub stack without creating gh-stack local tracking state—along with full documentation and test coverage.
Changes:
- Introduces
gh stack linkCLI command and wires it into the root command. - Implements link flow: push branch args, resolve/create PRs, fix base-branch chaining, then create/update the remote stack (additive-only).
- Adds extensive unit tests plus updates README, CLI reference docs, FAQ, and the gh-stack skill guide.
Show a summary per file
| File | Description |
|---|---|
| skills/gh-stack/SKILL.md | Updates agent rules and adds a new section documenting gh stack link. |
| docs/src/content/docs/reference/cli.md | Adds CLI reference documentation for gh stack link. |
| docs/src/content/docs/faq.md | Updates FAQ to recommend gh stack link for external stacking tools. |
| cmd/root.go | Registers LinkCmd in the CLI. |
| cmd/link.go | Implements the link command (push/resolve/create/fix-base/upsert-stack). |
| cmd/link_test.go | Adds comprehensive tests for PR-number, branch-name, and mixed workflows. |
| README.md | Documents gh stack link usage and flags. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 5
0b144cc to
32de12d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh stack link— stacks API-wrapper for external tool usersUsers who manage branches with external tools (jj, Sapling, ghstack, git-town) currently need to run
init --adopt+submitto create GitHub stacks — but that creates local tracking state they don't want. This adds a lightweightgh stack linkcommand that works entirely via the GitHub API without creating/modifying any local state.Usage:
Arguments can be branch names, PR numbers, or a mix. Branches are pushed automatically, PRs are created for branches that don't have them, and the PRs are linked as a stack on GitHub.
How it works:
FindPRByNumberfirst; if not found, fall through to branch lookup viaFindPRForBranchListStacksand checks that the operation won't remove existing PRs from a stack (additive-only safety). Fails early before creating any new PRs--base, subsequent branches chain off the previous)BaseRefNameon existing PRs whose base doesn't match the expected chain (skips newly created PRs)Safety features:
FindPRByNumberAPI errors are treated as fatal (not silently falling through to branch-name lookup)ListStackscall — pre-validation and upsert share the same API responseFlags:
--base <branch>main)--draft--remote <name>