fix(git): hide stale merged/closed PRs on the default branch#1966
fix(git): hide stale merged/closed PRs on the default branch#1966GuilhermeVieiraDev wants to merge 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved A small, self-contained bug fix that adds a simple conditional to hide merged/closed PRs when on the default branch. The change has clear intent explained in comments, limited scope (single conditional check), and includes test coverage. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Added a filter so that merged and closed PRs are not surfaced when the current branch is the default branch (main/master). Open PRs on the default branch are still shown normally.
Why
When a PR was created with
mainas the head branch (e.g. a reverse merge from main into a feature branch), that merged PR would keep showing up in the sidebar status every time you were onmain. This happened becausefindLatestPrfalls back to the most recently updated PR regardless of state when no open PR exists.On a feature branch this fallback makes sense since seeing "PR merged" is useful feedback. On the default branch it's just noise from old reverse merges that aren't relevant to the current context.
The fix checks
isDefaultBranch(already available fromstatusDetails) and skips non-open PRs when it's true, keeping the feature branch behavior unchanged.I ran into this while working on
mainfor a smaller project that had an old reverse-merge PR. The merged PR kept showing up in the sidebar even though it wasn't relevant anymore.Checklist
Note
Low Risk
Low risk: small conditional change to
GitManagerstatus PR selection plus a focused test, affecting only whether PR metadata is shown while on the default branch.Overview
Updates
GitManagerremotestatusto suppress merged/closed PR matches when the current branch is the default branch, returningpr: nullunless the latest match is stillopen.Adds a regression test ensuring a merged PR with
headRefName: maindoes not appear in status while onmain.Reviewed by Cursor Bugbot for commit dda0993. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Hide stale merged/closed PRs from
manager.statuswhen on the default branchWhen
isDefaultBranchis true,manager.statusnow returnsnullforstatus.prif the latest PR is not in theopenstate. Previously, merged or closed PRs would still appear in status regardless of branch context. Behavioral Change: callers on the default branch that previously received a merged/closed PR instatus.prwill now receivenull.Macroscope summarized dda0993.