fix(server): preserve merged PR badges after branch deletion (#6216)

This commit is contained in:
Tristan Knight authored and GitHub committed 2026-08-24 02:54:47 -07:00
1 parent be3da50e96
commit ba30177b5a
2 files changed
+95 -13

No files matched your search

+26 -13
View File
@@ -1268,15 +1268,17 @@ export const make = Effect.gen(function* () {
* cannot exist for it and asking the provider is a guaranteed-empty API call.
*
* `git push` writes the remote-tracking ref even without `-u` (how most
* terminal and agent pushes land), which makes this a safer "did it ever
* reach the host" test than looking for upstream config, and the glob spans
* every remote so a fork branch still counts. A repository that tracks no
* remotes at all cannot answer the question, because then every branch looks
* unpublished; it, and any failed probe, keeps the lookup.
* terminal and agent pushes land), and configured upstream metadata survives
* when a merged change request's remote branch is deleted. Together they
* distinguish branches known to have reached a host from genuinely local
* branches. The ref glob spans every remote so a fork branch still counts. A
* repository that tracks no remotes at all cannot answer the question,
* because then every branch looks unpublished; it, and any failed probe,
* keeps the lookup.
*/
const isUnpublishedBranch = Effect.fn("isUnpublishedBranch")(function* (
cwd: string,
headContext: Pick<BranchHeadContext, "headBranch">,
headContext: Pick<BranchHeadContext, "headBranch" | "localBranch">,
) {
if (headContext.headBranch.length === 0) {
return false;
@@ -1291,13 +1293,24 @@ export const make = Effect.gen(function* () {
})
.pipe(Effect.map((result) => result.stdout.trim().length > 0));
return yield* Effect.all(
[matchesRef("refs/remotes"), matchesRef(`refs/remotes/*/${headContext.headBranch}`)],
{ concurrency: "unbounded" },
).pipe(
Effect.map(([tracksAnyRemote, tracksThisBranch]) => tracksAnyRemote && !tracksThisBranch),
Effect.orElseSucceed(() => false),
);
return yield* Effect.gen(function* () {
const [configuredRemote, configuredMerge] = yield* Effect.all(
[
gitCore.readConfigValue(cwd, `branch.${headContext.localBranch}.remote`),
gitCore.readConfigValue(cwd, `branch.${headContext.localBranch}.merge`),
],
{ concurrency: "unbounded" },
);
if (configuredRemote !== null && configuredMerge !== null) {
return false;
}
const [tracksAnyRemote, tracksThisBranch] = yield* Effect.all(
[matchesRef("refs/remotes"), matchesRef(`refs/remotes/*/${headContext.headBranch}`)],
{ concurrency: "unbounded" },
);
return tracksAnyRemote && !tracksThisBranch;
}).pipe(Effect.orElseSucceed(() => false));
});
const findOpenPr = Effect.fn("findOpenPr")(function* (