fix(github): omit local-only branches from PR stack comments#37
Merged
fix(github): omit local-only branches from PR stack comments#37
Conversation
Owner
Author
📚 Pull Request Stack
Managed by gh-stack |
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
782193d to
e84d08d
Compare
There was a problem hiding this comment.
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 togit.Gitto read cached remote-tracking refs without making a network call - Enhanced
GenerateStackCommentand related functions to accept an optionalremoteBranchesparameter 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
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.
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.ListRemoteBranches()togit.Git(reads cached trackingrefs, no network call)
GenerateStackComment/renderTreeaccept an optionalremoteBranchesset;nildisables filteringfindEffectiveParent()walks ancestors to find the nearest visibleparent for the warning header
submitandsynccommand paths