fix(server): preserve merged PR badges after branch deletion #6216
main fromrefs/pull/6216/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubA merged or closed PR badge disappeared when its remote head branch was deleted. Git could no longer resolve the upstream ref, and the unpublished-branch optimization treated the missing remote-tracking ref as proof that the branch had never been published, suppressing the provider lookup.
Treat a branch as definitely unpublished only when it has neither a matching remote-tracking ref nor complete branch remote/merge configuration. The latter survives deletion of a tracked remote branch, so the provider can still discover the merged or closed change request while genuinely local branches keep the API-call optimization.
Verification:
pnpm exec vp test run apps/server/src/git/GitManager.test.ts(82 passed)- targeted formatting and lint checks passed
- server typecheck passed
Implemented with GPT-5.6-sol via the Codex harness in T3 Code.
Note
Low Risk Narrow change to the unpublished-branch skip used for PR lookup; local-only branches still skip the API, and a targeted test covers the deleted-remote-branch case.
Overview Fixes git status so a merged/closed PR badge still appears after GitHub deletes the remote head branch.
isUnpublishedBranch no longer treats a missing remote-tracking ref as “never published.” If branch.<local>.remote and branch.<local>.merge are still set (Git keeps those after a delete), the branch is treated as published and the provider lookup still runs. Genuinely local branches keep the skip.
Adds a regression test that deletes the remote branch, asserts hasUpstream is false, and still returns the merged PR.
Note
Fix GitManager.make.isUnpublishedBranch to read git config for upstream metadata#
When GitHub auto-deletes a merged PR's head branch, the remote-tracking ref disappears but local git config (branch.<name>.remote and branch.<name>.merge) persists. The old logic relied only on remote-tracking ref presence, so these branches were misclassified as unpublished and PR lookups were skipped.
isUnpublishedBranchnow accepts bothheadBranchandlocalBranch, and first checks the git config keys forlocalBranch; if both are present, the branch is treated as published- Falls back to checking remotes and remote-tracking refs for
headBranchonly when config keys are absent - Adds a test in GitManager.test.ts verifying that
manager.statusreturnshasUpstream: falsebut still populates PR metadata with a merged state after branch deletion - Risk: branches pushed without
-uthat have neither config keys nor remote-tracking refs remain unpublished — no change to those; but any branch with stalebranch.<name>.mergeconfig pointing at a deleted upstream will now trigger a provider PR lookup it would not have before
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Skipped
Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.
GPT-5.6-sol via Codex, responding on behalf of @tris203:
Thanks for flagging this. The direct
gitCore.readConfigValuecalls are intentional here. A missing config key is returned asnull, so the remote-ref checks still run and genuinely unpublished branches retain the API-call optimization. A Git/config command failure instead propagates to the outerorElseSucceed(() => false), which means “we cannot prove this branch is unpublished” and preserves the provider lookup.Using
readConfigValueNullablewould collapse a command failure intonull, allowing the subsequent ref checks to classify the branch as unpublished and potentially suppress a real PR lookup during a transient Git failure. The conservative fallback is therefore deliberate and matches the existing function comment that any failed probe keeps the lookup.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
88397bf6-3328-4cf5-a3cd-b408cbebb8c7You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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.
❤️ Share