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 - #10

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

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

Conversation

@github-actions

Copy link
Copy Markdown

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

Problem

gh stack view --json sets needsRebase: true for branches whose PR is currently in the merge queue. This is incorrect: a branch in the merge queue cannot be rebased β€” doing so would invalidate the queue entry. Any automation script that checks needsRebase and acts on it (e.g. by running gh stack rebase) would fail or silently corrupt the queued PR.

Root cause

In viewJSON (cmd/view.go), NeedsRebase was skipped for merged branches but not for queued ones:

// Before
if !jb.IsMerged {
    baseBranch := s.ActiveBaseBranch(b.Branch)
    if isAnc, err := git.IsAncestor(baseBranch, b.Branch); err == nil && !isAnc {
        jb.NeedsRebase = true
    }
}

Fix

Mirror the existing merged-branch skip for queued branches:

// After
if !jb.IsMerged && !jb.IsQueued {
    baseBranch := s.ActiveBaseBranch(b.Branch)
    if isAnc, err := git.IsAncestor(baseBranch, b.Branch); err == nil && !isAnc {
        jb.NeedsRebase = true
    }
}

Test

Added TestViewJSON_QueuedBranchNeedsRebaseFalse in cmd/view_test.go:

  • Configures IsAncestor to return false for all branches (worst case)
  • Verifies queued branch has needsRebase: false
  • Verifies non-queued open branch still has needsRebase: true

Test Status

Tests could not be run in this environment (Go 1.25.7 toolchain download requires sum.golang.org, which is blocked by the firewall). CI will run the full test suite. The change is a single-line predicate addition in a well-understood path with a new test covering the invariant directly.

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

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • sum.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "sum.golang.org"

See Network Configuration for more information.

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]>
@github-actions github-actions Bot added automation bug Something isn't working repo-assist labels Apr 17, 2026
@github-actions github-actions Bot mentioned this pull request Apr 18, 2026
20 tasks
@github-actions

Copy link
Copy Markdown
Author

πŸ€– This is an automated message from Repo Assist.

This PR (#10) is superseded by PR #11, which contains the same fix plus additional improvements (it also ensures needsRebase is correctly suppressed for queued branches across all affected code paths, with a dedicated test).

Once PR #11 is reviewed, this PR (#10) can be safely closed. Sorry for the noise β€” I created #11 after catching additional cases while working on the fix.

Generated by 🌈 Repo Assist, see workflow run.

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

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