[Repo Assist] Fix needsRebase=true incorrectly set for queued branches in JSON output - #11
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
Branches in the merge queue cannot be rebased. Reporting needsRebase=true for them misleads automation scripts that consume `gh stack view --json` output β a script that rebases when needsRebase=true would fail or corrupt a queued PR. Fix: skip the IsAncestor check when the branch is queued (IsQueued=true), mirroring the existing skip for merged branches. Add TestViewJSON_QueuedBranchNeedsRebaseFalse to cover this invariant. Co-authored-by: Copilot <[email protected]>
20 tasks
This was referenced Apr 28, 2026
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.
π€ This is an automated pull request from Repo Assist, an AI assistant.
Summary
gh stack view --jsoncould return"needsRebase": truefor branches that are already in the merge queue. This is misleading: queued branches cannot be rebased (the merge queue owns the branch state), so reportingneedsRebase=truebreaks automation scripts that use the JSON output to decide whether to rebase.Root Cause
viewJSONincmd/view.gochecked!jb.IsMergedbefore computingneedsRebase, but did not exclude queued branches. TheIsAncestorcheck can returnfalsefor queued branches (they may have diverged from their base while waiting in the queue), which incorrectly setsneedsRebase=true.Fix
Add
!jb.IsQueuedto the guard condition:This ensures queued branches are treated like merged ones for the rebase-check: skipped entirely, always reporting
needsRebase: false.Test
Added
TestViewJSON_QueuedBranchNeedsRebaseFalsethat:git.IsAncestorto always returnfalse(simulating diverged history)needsRebase: falseneedsRebase: trueTest Status
Tests could not be run in this environment because the Go toolchain requires network access to
proxy.golang.org/sum.golang.org(blocked by firewall). The CI workflow will run the full test suite. The change is a two-character guard addition in a well-understood code path.