Append to an existing stack by stack number with link#181
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds stack-number-based append support to gh stack link.
Changes:
- Detects a leading stack number and appends only new PRs.
- Preserves base chaining, eligibility checks, and idempotency.
- Updates tests and documentation.
Show a summary per file
| File | Description |
|---|---|
cmd/link.go |
Implements stack-number append mode. |
cmd/link_test.go |
Adds append-mode coverage. |
docs/src/content/docs/reference/cli.md |
Documents CLI usage. |
docs/src/content/docs/faq.md |
Updates stack-growth guidance. |
skills/gh-stack/SKILL.md |
Updates agent instructions. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Medium
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.
Builds on the stack-number work:
gh stack linkpreviously required you to list every PR in a stack each time you touched it. Adding one PR to the top meant re-typing the whole chain, and leaving one out failed withthis would remove #… from the stack. This PR lets you pass a stack number as the first argument and append only the new PRs to the top of that stack, so growing a stack no longer means restating it. The create-from-scratch and additive-update forms are unchanged.What's new
gh stack link <stack-number> <pr-or-branch>…— when the first argument is a stack number (the identifier shown in the GitHub stack UI), the remaining PRs/branches are appended to the top of that stack, e.g.gh stack link 7 48 ui-polish. You no longer restate the PRs already in it.unstack it first) — you can grow a stack, but not merge two together.--basehas no effect in this mode and says so.The original forms —
gh stack link a b cto create, andgh stack link 41 42 new-branchto additively update — behave exactly as before.Changes
Append to a stack by number
cmd/link.go—runLinknow lists stacks up front, anddetectAddModesplits a leading stack number from the PRs to append. A newrunLinkAddpath partitions the arguments into already-present (skipped) and new, enforces the single-stack constraint, validates eligibility of the new PRs, chains them onto the stack's current top branch, and appends the delta through theAddToStackendpoint (reusing the update path's404/422handling). The existing create/update logic moves intorunLinkCreateOrUpdate, andcreateMissingPRs/fixBaseBranchesgain abottomBaseargument so both paths share the base-chaining. A best-effortGetStackfallback covers the case where the stack list omits per-PR head refs.Docs
docs/src/content/docs/reference/cli.md,faq.md, andskills/gh-stack/SKILL.md— document the stack-number-first form and replace the old "runlinkagain with the full list of PRs" guidance.Testing
cmd/link_test.gocases: add-mode append by number, branch creation chained on top of a stack, idempotent skip (all-present and mixed), cross-stack rejection, eligibility with the existing-member exemption, a numeric first argument that is a PR (not a stack) falling through to create/update, the--basewarning, multi-PR base chaining,404/422handling, and the list-lacks-head-refs fallback.go test -race -count=1 ./...andgo vet ./...are clean, and the changed files passgofmt.Stack created with GitHub Stacks CLI • Give Feedback 💬