Conversation
There was a problem hiding this comment.
Pull request overview
Assorted bugfixes across the gh stack CLI aimed at making stack rebases/syncs safer with remote changes, and making the TUI diff stats accurate when branches diverge from trunk. Also updates docs copy and the docs site social/diagram assets.
Changes:
- Fix
gh stack viewTUI diff/file counts by always anchoring diffs at thegit merge-basefork point. - In
syncandrebase, fast-forward local stack branches that are strictly behind their remote tracking branches before cascading rebases. - Avoid rev-parse failures when merged branches have been deleted by skipping non-existent merged branches during ref snapshotting; plus docs/site updates (OG tags, inline SVG component, social card).
Show a summary per file
| File | Description |
|---|---|
| skills/gh-stack/SKILL.md | Updates CLI workflow documentation wording around merge handling and rebase behavior. |
| internal/tui/stackview/data.go | Uses git merge-base for diff base selection for all branches to avoid inflated diffs. |
| internal/tui/stackview/data_test.go | Adds tests covering merge-base anchoring in diverged and linear histories. |
| internal/git/git.go | Updates comment wording around --onto usage for merged PR scenarios. |
| cmd/utils.go | Adds fastForwardBranches helper to advance local refs when behind remote. |
| cmd/sync.go | Runs branch fast-forwarding prior to cascade rebase; skips non-existent merged branches in ref snapshot. |
| cmd/sync_test.go | Expands sync tests for branch FF triggering rebase and merged-branch-deletion scenarios. |
| cmd/rebase.go | Runs branch fast-forwarding prior to cascade rebase; skips non-existent merged branches in ref snapshot. |
| cmd/rebase_test.go | Adds rebase tests for FF behavior and merged-branch-deletion scenarios. |
| docs/src/content/docs/reference/cli.md | Updates rebase command documentation wording (merged PR handling). |
| README.md | Updates rebase command documentation wording (merged PR handling). |
| docs/src/content/docs/index.mdx | Switches from static SVG asset to an Astro component for the stack diagram. |
| docs/src/components/StackDiagram.astro | New inline-SVG diagram component to improve theme behavior and Safari compatibility. |
| docs/src/assets/stack-diagram.svg | Removes the old static SVG asset. |
| docs/public/github-social-card.jpg | Adds a social preview image used by OG/Twitter meta tags. |
| docs/astro.config.mjs | Updates site description and adds OG/Twitter meta tags for social sharing. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 14/16 changed files
- Comments generated: 5
0779491 to
2267892
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.
Assorted bugfixes for rebase, sync, and view
1. Fix inflated diff counts in
gh stack viewTUIWhen the local base branch (e.g.
main) had advanced past a branch's fork point,gh stack viewshowed inflated file counts and diff stats because the two-dot diff compared full trees instead of diffing from the fork point.Fix: Always use
git merge-baseto find the fork point for diff computation, not just for merged branches.2. Fast-forward stack branches that are behind their remote
In certain situations, when there was an upstream commit not present on local,
gh stack rebaseandgh stack syncwould rebase on top of the stale local ref, effectively dropping the new commits.Fix: Before the cascade rebase, both
rebaseandsyncnow detect stack branches where the local ref is strictly behind the remote tracking branch and fast-forward them. If the branch has diverged, it's left alone (the push step handles that). Forsync, a branch fast-forward also triggers the cascade rebase even if trunk hasn't moved.3. Fix rev-parse error when rebasing over deleted branches
When a merged branch's remote ref was deleted (e.g. "Automatically delete head branches"),
gh stack rebasewould fail with a rev-parse error because it tried to resolve refs for all branches, including ones that no longer exist.Fix: Filter out merged branches that don't exist locally before calling
RevParseMultito snapshot original refs. These branches are already skipped during the actual rebase cascade.4. Fix rev-parse error during sync with deleted branches
Same root cause as 3, but in the
gh stack synccode path. The branch-ref snapshot before rebase included deleted branches, causing a rev-parse failure.Fix: Apply the same guard — skip merged branches that don't exist locally when building the ref snapshot.
5. Fix
--ontorebase for merged branches (fixes #31)When a branch in the stack is merged on remote, subsequent
rebaseandsyncoperations need to usegit rebase --ontoto transplant the next branch onto trunk. Fixes for this in a couple of areas:originalRefshad no entry andontoOldBasewas empty — causinggit rebase --onto main "" b2to fail. Fixed by backfillingoriginalRefsfrom the persistedBranchRef.HeadSHA in the stack file.--upstackflag: When using--upstack, the rebase loop starts at the current branch, so it never iterates over merged branches below it and never setsneedsOnto. Fixed by checking the immediate predecessor first.IsAncestorguard that falls back tomerge-basewhen the old base is stale.6. Pre-flight check for stacked PR availability in
gh stack submitWhen running
gh stack submiton a repo that doesn't have stacked PRs enabled, the command would push branches and create PRs before discovering that stacked PRs aren't enabled for the repository.Fix: Before pushing or creating PRs,
submitnow calls the list stacks API to verify stacked PRs is enabled on the repo. If stacks aren't available, the user is prompted interactively to create regular (unstacked) PRs instead. In non-interactive mode, the command exits with an error.Also includes some minor fixes for styling on the docs site.