Skip to content

Commit 0478c41

Browse files
Fix cross-repo PR selector ordering and base branch candidate normalization
- Reorder headSelectors so owner-qualified selectors (e.g. octocat:branch) come before bare branch names when isCrossRepository is true, preventing an unrelated same-repo PR from being matched first. - Extend base branch candidate normalization to strip the dynamic primaryRemoteName prefix (not just hardcoded 'origin/'), so candidates stored with a non-origin remote prefix are correctly normalized. Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
1 parent 1dc2116 commit 0478c41

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

apps/server/src/git/Layers/GitCore.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,13 @@ const makeGitCore = Effect.gen(function* () {
565565
continue;
566566
}
567567

568+
const remotePrefix =
569+
primaryRemoteName && primaryRemoteName !== "origin" ? `${primaryRemoteName}/` : null;
568570
const normalizedCandidate = candidate.startsWith("origin/")
569571
? candidate.slice("origin/".length)
570-
: candidate;
572+
: remotePrefix && candidate.startsWith(remotePrefix)
573+
? candidate.slice(remotePrefix.length)
574+
: candidate;
571575
if (normalizedCandidate.length === 0 || normalizedCandidate === branch) {
572576
continue;
573577
}

apps/server/src/git/Layers/GitManager.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,19 @@ export const makeGitManager = Effect.gen(function* () {
489489
const shouldProbeRemoteOwnedSelectors = isCrossRepository || (remoteName !== null && remoteName !== "origin");
490490

491491
const headSelectors: string[] = [];
492+
if (isCrossRepository && shouldProbeRemoteOwnedSelectors) {
493+
appendUnique(headSelectors, ownerHeadSelector);
494+
appendUnique(headSelectors, remoteAliasHeadSelector !== ownerHeadSelector ? remoteAliasHeadSelector : null);
495+
}
492496
appendUnique(headSelectors, details.branch);
493497
appendUnique(headSelectors, headBranch !== details.branch ? headBranch : null);
494-
appendUnique(headSelectors, shouldProbeRemoteOwnedSelectors ? ownerHeadSelector : null);
495-
appendUnique(
496-
headSelectors,
497-
shouldProbeRemoteOwnedSelectors && remoteAliasHeadSelector !== ownerHeadSelector
498-
? remoteAliasHeadSelector
499-
: null,
500-
);
498+
if (!isCrossRepository && shouldProbeRemoteOwnedSelectors) {
499+
appendUnique(headSelectors, ownerHeadSelector);
500+
appendUnique(
501+
headSelectors,
502+
remoteAliasHeadSelector !== ownerHeadSelector ? remoteAliasHeadSelector : null,
503+
);
504+
}
501505

502506
return {
503507
localBranch: details.branch,

0 commit comments

Comments
 (0)