Skip to content

fix(github): omit local-only branches from PR stack comments#37

Merged
boneskull merged 2 commits intomainfrom
pr-check-remote-branches
Feb 14, 2026
Merged

fix(github): omit local-only branches from PR stack comments#37
boneskull merged 2 commits intomainfrom
pr-check-remote-branches

Conversation

@boneskull
Copy link
Copy Markdown
Owner

Branches without PRs that don't exist on the remote are now filtered out of the rendered stack comment and the [!WARNING] header. Their children are promoted up a level so the tree stays connected.

  • Add ListRemoteBranches() to git.Git (reads cached tracking
    refs, no network call)
  • GenerateStackComment / renderTree accept an optional
    remoteBranches set; nil disables filtering
  • findEffectiveParent() walks ancestors to find the nearest visible
    parent for the warning header
  • Thread the set through submit and sync command paths

@boneskull
Copy link
Copy Markdown
Owner Author

boneskull commented Feb 13, 2026

📚 Pull Request Stack


Managed by gh-stack

Base automatically changed from fix-pr-comment-tree to main February 13, 2026 23:59
Branches without PRs that don't exist on the remote are now filtered
out of the rendered stack comment and the `[!WARNING]` header. Their
children are promoted up a level so the tree stays connected.

- Add `ListRemoteBranches()` to `git.Git` (reads cached tracking
  refs, no network call)
- `GenerateStackComment` / `renderTree` accept an optional
  `remoteBranches` set; `nil` disables filtering
- `findEffectiveParent()` walks ancestors to find the nearest visible
  parent for the warning header
- Thread the set through `submit` and `sync` command paths
@boneskull boneskull force-pushed the pr-check-remote-branches branch from 782193d to e84d08d Compare February 14, 2026 00:00
@boneskull boneskull marked this pull request as ready for review February 14, 2026 00:00
Copilot AI review requested due to automatic review settings February 14, 2026 00:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a UX issue where local-only branches (branches without PRs that haven't been pushed to the remote) were appearing in PR stack comments on GitHub. The solution filters these branches out of the rendered comment and promotes their children up in the tree hierarchy to keep the stack visualization connected.

Changes:

  • Added ListRemoteBranches() method to git.Git to read cached remote-tracking refs without making a network call
  • Enhanced GenerateStackComment and related functions to accept an optional remoteBranches parameter for filtering
  • Implemented findEffectiveParent() to walk up the tree and find the nearest visible ancestor for the warning header

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/git/git.go Added ListRemoteBranches() to query locally-cached remote refs using git for-each-ref
internal/github/comments.go Added filtering logic to skip local-only branches in renderTree() and find effective parent in findEffectiveParent() for warning headers
internal/github/comments_test.go Updated all existing tests to pass nil for the new parameter and added comprehensive tests for remote branch filtering behavior
cmd/submit.go Threaded remoteBranches through all PR creation/update paths with graceful error handling
cmd/sync.go Added remoteBranches parameter to comment update flow with non-fatal error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add defensive `!isCurrent` guard to `skipNode` in `renderTree`
- Assert WARNING header absent when effective parent is trunk after filtering
- Assert WARNING header references correct non-trunk remote parent
- Add test for multiple consecutive local-only branches being filtered
@boneskull boneskull merged commit f4afa45 into main Feb 14, 2026
7 checks passed
@boneskull boneskull deleted the pr-check-remote-branches branch February 14, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants