Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Repo Assist] Fix needsRebase=true incorrectly set for queued branches in JSON output - #11

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-needsrebase-queued-2026-04-18-75769f450f17c2af
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-needsrebase-queued-2026-04-18-75769f450f17c2af

Conversation

@github-actions

Copy link
Copy Markdown

πŸ€– This is an automated pull request from Repo Assist, an AI assistant.

Summary

gh stack view --json could return "needsRebase": true for branches that are already in the merge queue. This is misleading: queued branches cannot be rebased (the merge queue owns the branch state), so reporting needsRebase=true breaks automation scripts that use the JSON output to decide whether to rebase.

Root Cause

viewJSON in cmd/view.go checked !jb.IsMerged before computing needsRebase, but did not exclude queued branches. The IsAncestor check can return false for queued branches (they may have diverged from their base while waiting in the queue), which incorrectly sets needsRebase=true.

Fix

Add !jb.IsQueued to the guard condition:

// Before
if !jb.IsMerged {

// After
if !jb.IsMerged && !jb.IsQueued {

This ensures queued branches are treated like merged ones for the rebase-check: skipped entirely, always reporting needsRebase: false.

Test

Added TestViewJSON_QueuedBranchNeedsRebaseFalse that:

  • Mocks git.IsAncestor to always return false (simulating diverged history)
  • Verifies that a queued branch reports needsRebase: false
  • Verifies that an adjacent open branch still correctly reports needsRebase: true

Test 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.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@11c9a2c442e519ff2b427bf58679f5a525353f76

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation bug Something isn't working repo-assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants