fix for rev-parse error during sync with deleted branches#42
Open
skarim wants to merge 2 commits intoskarim/fix-rebase-deletedfrom
Open
fix for rev-parse error during sync with deleted branches#42skarim wants to merge 2 commits intoskarim/fix-rebase-deletedfrom
skarim wants to merge 2 commits intoskarim/fix-rebase-deletedfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates gh-stack’s sync/rebase behavior and documentation around handling merged PRs (previously described as “squash-merged”), including a new test case for merged branches that no longer exist locally (e.g., deleted after merge).
Changes:
- Adjusts
sync’s pre-rebase “original refs” capture to skip merged branches that don’t exist locally. - Renames “squash-merged” terminology to “merged” across CLI docs, README, skill docs, messages, and tests.
- Adds/updates tests to cover merged-branch
--ontobehavior and a “merged branch deleted from remote” scenario.
Show a summary per file
| File | Description |
|---|---|
| skills/gh-stack/SKILL.md | Updates user-facing documentation wording from squash-merge to merged PR handling. |
| internal/git/git.go | Updates RebaseOnto doc comment terminology to “merged”. |
| docs/src/content/docs/reference/cli.md | Updates CLI reference text to describe merged PR detection for --onto. |
| cmd/sync_test.go | Renames tests and adds coverage for merged-branch scenarios, including missing local branch. |
| cmd/sync.go | Skips non-existent merged branches when collecting SHAs for conflict-restore bookkeeping. |
| cmd/rebase_test.go | Renames tests/comments to match “merged” terminology. |
| cmd/rebase.go | Updates comments/messages to match “merged” terminology. |
| README.md | Updates README description of merged PR handling during rebase. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
cmd/rebase.go:209
- The merged-branch skip path sets
ontoOldBase = originalRefs[br.Branch]. If a merged branch was deleted locally and therefore excluded from theRevParseMapinputs, this lookup will be empty and subsequentRebaseOnto(newBase, ontoOldBase, ...)will run with an invalid oldBase. Consider using the persisted SHA from stack metadata (e.g.,br.Head) when the ref is missing, and fail fast with a clear message if you can't determine an oldBase SHA.
// Skip branches whose PRs have already been merged.
// Record state so subsequent branches can use --onto rebase.
if br.IsMerged() {
ontoOldBase = originalRefs[br.Branch]
needsOnto = true
cfg.Successf("Skipping %s (PR %s merged)", br.Branch, cfg.PRLink(br.PullRequest.Number, br.PullRequest.URL))
- Files reviewed: 8/8 changed files
- Comments generated: 3
Lukeghenco
approved these changes
Apr 16, 2026
08a7f7b to
fba004c
Compare
d277c87 to
63f019e
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.
Fix rev-parse error during sync with deleted branches
Same root cause as the rebase fix, 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.