gh-stack icon indicating copy to clipboard operation
gh-stack copied to clipboard

4 issues found adopting gh-stack on an existing (non-stacked) set of open PRs

Open chene-bit opened this issue 2 months ago • 0 comments

Context

We adopted gh-stack mid-flight on a real repo: 4 already-open, already-reviewed PRs that were siblings off the same trunk instead of a real stack, plus a later test where we pushed a file-rename commit to the trunk and cascaded it through the stack with gh stack rebase. Overall the tool did what it promised — clean cascading rebase, atomic push, clean PR base retargeting. Four issues stood out enough to be worth flagging:

1. gh stack link can't insert a PR below an existing stack

The docs/examples for link suggest it's meant for gradual adoption of pre-existing PRs. We linked 2 PRs into a stack first (bottom + top layer), then tried to add a third PR underneath the existing bottom layer via gh stack link --base trunk lower-pr existing-bottom existing-top. It failed with:

✗ Cannot update stack: new PRs must be added to the top of the existing stack

and, digging further, changing an existing stacked PR's base directly via the API returns:

Cannot change the base branch because the pull request is part of a stack.

So the only path we found was gh stack unstack <n> and relinking all PRs from scratch in the correct order. For anyone adopting gh-stack incrementally on existing PRs (exactly the "gradual adoption" use case link is pitched for), discovering the right bottom-up order up front isn't always possible — this should either be supported directly, or the error message should say so explicitly instead of only mentioning "top of stack."

2. Rebase can produce a synthesized, useless file when both a lower and an upper layer rename the same original file differently

We hit this concretely: a trunk-level commit renamed show-bands.ts → show-bands.component.ts. A downstream branch had its own older commit renaming the same original file show-bands.ts → bands-list.ts. Cascading the rebase produced the correct bands-list.* files and a spurious bands-list/show-bands.component.* set (conflict-marked, containing stale duplicate content) that isn't mentioned anywhere in the tool's guidance. git status after resolving the "real" conflict still showed unresolved both deleted/added by them entries for these synthesized paths — easy to miss if you don't inspect the full status.

Suggestion: when a rebase conflict involves a rename on both sides of a 3-way merge, surface a specific warning (not just generic conflict markers) so people know to check for and clean up a second, unwanted destination path.

3. Nothing verifies the result of a rebase/sync — silent "clean" cascades can still leave the build broken

This was the biggest one in practice. Multiple times, gh stack rebase/sync reported success with zero conflicts, but the result didn't compile — because a lower layer renamed a file, and an upper layer's own commit referenced the old filename in a plain string (templateUrl, styleUrl, an import path) rather than as a git-tracked path. Git's conflict detection is line-based and has no idea those strings are related to the renamed file, so it merges "cleanly" into a broken build. This happened 4 separate times across one cascade.

Suggestion: an opt-in --verify <command> (or auto-detect a build/test package.json script) that runs after each layer is rebased, so a broken layer is caught and reported before push, rather than relying on the user to manually build/test every branch in isolation after the fact.

4. What worked well (worth keeping / calling out)

  • gh stack sync's conflict handling is genuinely good: on conflict it fully restores all branches to their pre-sync state and tells you to run gh stack rebase interactively instead of leaving things half-migrated. No partial damage, no ambiguity about what state you're in.
  • --base for a non-default trunk worked exactly as documented — useful for repos (like ours, a shared training/exercises repo) where the real integration branch isn't the repository's default branch.
  • link's "GitHub-side only, no local tracking, no rebase" mode is a genuinely safe way to try the tool against already-open PRs without committing to anything — we used it as a zero-risk first step before doing any real rebasing.

🤖 Generated with Claude Code

chene-bit avatar Sep 29 '26 08:09 chene-bit