TypeScript
fix(server): a branch on the only remote is not a fork when there is no origin (#20412)
Victor Vogel2c8f3a0cfcf3
diff --git a/apps/server/src/git/GitManager.test.ts b/apps/server/src/git/GitManager.test.tsindex 7c39e58f888..bad1a80b371 100644--- a/apps/server/src/git/GitManager.test.ts+++ b/apps/server/src/git/GitManager.test.ts@@ -47,6 +47,7 @@ import {import * as DateTime from "effect/DateTime";import { decodeGitHubPullRequestListJson } from "@t3tools/source-control-github/server/gitHubPullRequests";import * as GitHubChangeRequestTemplate from "@t3tools/source-control-github/server/gitHubChangeRequestTemplate";+import * as HostProcess from "@t3tools/shared/HostProcess";import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli";import type * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost";@@ -718,6 +719,7 @@ function makeManager(input?: {setupScriptRunner?: ProjectSetupScriptRunner.ProjectSetupScriptRunner["Service"];gitConfigReads?: string[];gitCommands?: string[];+ environment?: NodeJS.ProcessEnv;gitSpawnGate?: {readonly matches: (args: ReadonlyArray<string>) => boolean;readonly reached: Deferred.Deferred<void>;@@ -845,6 +847,7 @@ function makeManager(input?: {yield* input.seed.pipe(Effect.provideContext(stores), Effect.orDie);}const manager = yield* GitManager.make.pipe(+ Effect.provideService(HostProcess.Environment, input?.environment ?? {}),Effect.provide(layerManager),Effect.provideContext(stores),);@@ -2668,6 +2671,13 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {yield* initRepo(repoDir);const forkDir = yield* createBareRemote();yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);+ // Origin is the base repository; a lone remote would be the base itself.+ yield* runGit(repoDir, [+ "remote",+ "add",+ "origin",+ "[email protected]:pingdotgg/codething-mvp.git",+ ]);yield* runGit(repoDir, ["checkout", "-b", "statemachine"]);NodeFS.writeFileSync(NodePath.join(repoDir, "fork-pr.txt"), "fork pr\n");yield* runGit(repoDir, ["add", "fork-pr.txt"]);@@ -4413,6 +4423,13 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {yield* runGit(repoDir, ["checkout", "-b", "statemachine"]);const forkDir = yield* createBareRemote();yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);+ // Origin is the base repository; a lone remote would be the base itself.+ yield* runGit(repoDir, [+ "remote",+ "add",+ "origin",+ "[email protected]:pingdotgg/codething-mvp.git",+ ]);yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);yield* configureVisibleRemoteUrlWithLocalRewrite(repoDir,@@ -4462,6 +4479,335 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {12_000,);+ it.effect.each([+ { remoteUrl: "[email protected]:pingdotgg/codething-mvp.git", ghRepo: null, ghResolved: null },+ {+ remoteUrl: "[email protected]:pingdotgg/codething-mvp.git",+ ghRepo: "https://github.com/pingdotgg/codething-mvp?tab=readme#readme",+ ghResolved: null,+ },+ {+ remoteUrl: "https://github.example.com:8443/pingdotgg/codething-mvp.git",+ ghRepo: "https://github.example.com:8443/pingdotgg/codething-mvp",+ ghResolved: null,+ },+ // The GitHub resolver finds no repository for this GitLab remote, so the remote decides.+ {+ remoteUrl: "https://gitlab.example.com:8443/pingdotgg/codething-mvp.git",+ ghRepo: null,+ ghResolved: null,+ },+ // With a port on the remote's host the provider ignores gh-resolved and picks the remote.+ {+ remoteUrl: "https://github.example.com:8443/pingdotgg/codething-mvp.git",+ ghRepo: null,+ ghResolved: "acme/demo",+ },+ {+ remoteUrl: "https://github.example.com:8443/pingdotgg/codething-mvp.git",+ ghRepo: "base",+ ghResolved: "acme/demo",+ },+ ] as const)(+ "reuses the open same-repository PR when the only remote is not named origin (remote $remoteUrl, GH_REPO $ghRepo, gh-resolved $ghResolved)",+ ({ remoteUrl, ghRepo, ghResolved }) =>+ Effect.gen(function* () {+ const repoDir = yield* makeTempDir("t3code-git-manager-");+ yield* initRepo(repoDir);+ yield* runGit(repoDir, ["checkout", "-b", "dev"]);+ const remoteDir = yield* createBareRemote();+ yield* runGit(repoDir, ["remote", "add", "fork", remoteDir]);+ yield* runGit(repoDir, ["push", "-u", "fork", "dev"]);+ yield* configureVisibleRemoteUrlWithLocalRewrite(repoDir, "fork", remoteUrl, remoteDir);+ if (ghResolved !== null) {+ yield* runGit(repoDir, ["config", "remote.fork.gh-resolved", ghResolved]);+ }+ NodeFS.writeFileSync(NodePath.join(repoDir, "changes.txt"), "change\n");++ const { manager, ghCalls } = yield* makeManager({+ environment: ghRepo === null ? {} : { GH_REPO: ghRepo },+ ghScenario: {+ prListByHeadSelector: {+ dev: encodeCliJson([+ {+ number: 3,+ title: "Dev",+ url: "https://github.com/pingdotgg/codething-mvp/pull/3",+ baseRefName: "main",+ headRefName: "dev",+ state: "OPEN",+ isCrossRepository: false,+ headRepository: { nameWithOwner: "pingdotgg/codething-mvp" },+ headRepositoryOwner: { login: "pingdotgg" },+ },+ ]),+ },+ },+ });++ const result = yield* runStackedAction(manager, {+ cwd: repoDir,+ action: "commit_push_pr",+ });++ expect(result.push.status).toBe("pushed");+ expect(result.pr.status).toBe("opened_existing");+ expect(result.pr.number).toBe(3);+ expect(ghCalls.some((call) => call.startsWith("pr create "))).toBe(false);+ }),+ 12_000,+ );++ it.effect(+ "creates fork PRs with the owner head when gh's default repository is not the only remote",+ () =>+ Effect.gen(function* () {+ const repoDir = yield* makeTempDir("t3code-git-manager-");+ yield* initRepo(repoDir);+ yield* runGit(repoDir, ["checkout", "-b", "dev"]);+ const forkDir = yield* createBareRemote();+ yield* runGit(repoDir, ["remote", "add", "fork", forkDir]);+ yield* runGit(repoDir, ["push", "-u", "fork", "dev"]);+ yield* configureVisibleRemoteUrlWithLocalRewrite(+ repoDir,+ "fork",+ "https://github.com/contributor/demo.git",+ forkDir,+ );+ // What `gh repo set-default acme/demo` records when the default is not a remote.+ yield* runGit(repoDir, ["config", "remote.fork.gh-resolved", "acme/demo"]);+ NodeFS.writeFileSync(NodePath.join(repoDir, "changes.txt"), "change\n");++ const { manager, ghCalls } = yield* makeManager();++ const result = yield* runStackedAction(manager, {+ cwd: repoDir,+ action: "commit_push_pr",+ });++ expect(result.pr.status).toBe("created");+ expect(+ ghCalls.some(+ (call) => call.startsWith("pr create ") && call.includes("--head contributor:dev"),+ ),+ ).toBe(true);+ }),+ 12_000,+ );++ it.effect.each([+ { ghRepo: "acme/demo", ghResolved: null, head: "contributor:dev" },+ { ghRepo: "ghe.example.com/contributor/demo", ghResolved: null, head: "contributor:dev" },+ { ghRepo: "github.com/Contributor/demo", ghResolved: null, head: "dev" },+ {+ ghRepo: "https://github.com/contributor/demo?tab=readme#readme",+ ghResolved: null,+ head: "dev",+ },+ { ghRepo: "contributor/demo", ghResolved: "acme/demo", head: "dev" },+ { ghRepo: "acme/demo", ghResolved: "base", head: "contributor:dev" },+ // The provider ignores these GH_REPO values, so gh-resolved decides.+ { ghRepo: "junk/extra/contributor/demo", ghResolved: "acme/demo", head: "contributor:dev" },+ { ghRepo: "base", ghResolved: "acme/demo", head: "contributor:dev" },+ ] as const)(+ "creates the PR with head $head when GH_REPO is $ghRepo, gh-resolved is $ghResolved and the only remote is contributor/demo",+ ({ ghRepo, ghResolved, head }) =>+ Effect.gen(function* () {+ const repoDir = yield* makeTempDir("t3code-git-manager-");+ yield* initRepo(repoDir);+ yield* runGit(repoDir, ["checkout", "-b", "dev"]);+ const forkDir = yield* createBareRemote();+ yield* runGit(repoDir, ["remote", "add", "fork", forkDir]);+ yield* runGit(repoDir, ["push", "-u", "fork", "dev"]);+ yield* configureVisibleRemoteUrlWithLocalRewrite(+ repoDir,+ "fork",+ "https://github.com/contributor/demo.git",+ forkDir,+ );+ if (ghResolved !== null) {+ yield* runGit(repoDir, ["config", "remote.fork.gh-resolved", ghResolved]);+ }+ NodeFS.writeFileSync(NodePath.join(repoDir, "changes.txt"), "change\n");++ const { manager, ghCalls } = yield* makeManager({ environment: { GH_REPO: ghRepo } });++ const result = yield* runStackedAction(manager, {+ cwd: repoDir,+ action: "commit_push_pr",+ });++ expect(result.pr.status).toBe("created");+ expect(+ ghCalls.some((call) => call.startsWith("pr create ") && call.includes(`--head ${head} `)),+ ).toBe(true);+ }),+ 12_000,+ );++ it.effect.each([+ {+ remoteUrl: "https://github.example.com:8443/contributor/demo.git",+ ghRepo: "https://github.example.com:9443/contributor/demo",+ ghResolved: null,+ head: "contributor:dev",+ },+ {+ remoteUrl: "https://github.example.com:8443/contributor/demo.git",+ ghRepo: "github.example.com/contributor/demo",+ ghResolved: null,+ head: "contributor:dev",+ },+ {+ remoteUrl: "https://github.example.com:8443/contributor/demo.git",+ ghRepo: "github.example.com:8443/contributor/demo",+ ghResolved: null,+ head: "dev",+ },+ {+ remoteUrl: "https://github.example.com/contributor/demo.git",+ ghRepo: "github.example.com:443/contributor/demo",+ ghResolved: null,+ head: "dev",+ },+ // An SSH port is not part of the host the provider uses.+ {+ remoteUrl: "ssh://[email protected]:2222/contributor/demo.git",+ ghRepo: "github.example.com/contributor/demo",+ ghResolved: null,+ head: "dev",+ },+ // The provider ignores gh-resolved only when the remote's host carries a port.+ {+ remoteUrl: "https://github.example.com:8443/contributor/demo.git",+ ghRepo: null,+ ghResolved: "acme/demo",+ head: "dev",+ },+ {+ remoteUrl: "https://github.example.com/contributor/demo.git",+ ghRepo: null,+ ghResolved: "acme/demo",+ head: "contributor:dev",+ },+ {+ remoteUrl: "https://github.example.com:443/contributor/demo.git",+ ghRepo: null,+ ghResolved: "acme/demo",+ head: "contributor:dev",+ },+ {+ remoteUrl: "[email protected]:contributor/demo.git",+ ghRepo: null,+ ghResolved: "acme/demo",+ head: "contributor:dev",+ },+ {+ remoteUrl: "ssh://[email protected]:2222/contributor/demo.git",+ ghRepo: null,+ ghResolved: "acme/demo",+ head: "contributor:dev",+ },+ ] as const)(+ "creates the PR with head $head when the only remote is $remoteUrl, GH_REPO is $ghRepo and gh-resolved is $ghResolved",+ ({ remoteUrl, ghRepo, ghResolved, head }) =>+ Effect.gen(function* () {+ const repoDir = yield* makeTempDir("t3code-git-manager-");+ yield* initRepo(repoDir);+ yield* runGit(repoDir, ["checkout", "-b", "dev"]);+ const forkDir = yield* createBareRemote();+ yield* runGit(repoDir, ["remote", "add", "fork", forkDir]);+ yield* runGit(repoDir, ["push", "-u", "fork", "dev"]);+ yield* configureVisibleRemoteUrlWithLocalRewrite(repoDir, "fork", remoteUrl, forkDir);+ if (ghResolved !== null) {+ yield* runGit(repoDir, ["config", "remote.fork.gh-resolved", ghResolved]);+ }+ NodeFS.writeFileSync(NodePath.join(repoDir, "changes.txt"), "change\n");++ const { manager, ghCalls } = yield* makeManager({+ environment: ghRepo === null ? {} : { GH_REPO: ghRepo },+ });++ const result = yield* runStackedAction(manager, {+ cwd: repoDir,+ action: "commit_push_pr",+ });++ expect(result.pr.status).toBe("created");+ expect(+ ghCalls.some((call) => call.startsWith("pr create ") && call.includes(`--head ${head} `)),+ ).toBe(true);+ }),+ 12_000,+ );++ it.effect(+ "still treats a fork remote as cross-repository with an upstream remote but no origin",+ () =>+ Effect.gen(function* () {+ const repoDir = yield* makeTempDir("t3code-git-manager-");+ yield* initRepo(repoDir);+ yield* runGit(repoDir, ["checkout", "-b", "dev"]);+ const forkDir = yield* createBareRemote();+ yield* runGit(repoDir, ["remote", "add", "fork", forkDir]);+ yield* runGit(repoDir, ["push", "-u", "fork", "dev"]);+ yield* configureVisibleRemoteUrlWithLocalRewrite(+ repoDir,+ "fork",+ "https://github.com/contributor/demo.git",+ forkDir,+ );+ const upstreamDir = yield* createBareRemote();+ yield* runGit(repoDir, ["remote", "add", "upstream", upstreamDir]);+ yield* runGit(repoDir, ["push", "upstream", "main"]);+ yield* configureVisibleRemoteUrlWithLocalRewrite(+ repoDir,+ "upstream",+ "https://github.com/acme/demo.git",+ upstreamDir,+ );+ NodeFS.writeFileSync(NodePath.join(repoDir, "changes.txt"), "change\n");++ const sameRepositoryPr = {+ number: 3,+ title: "Same-repository decoy",+ url: "https://github.com/contributor/demo/pull/3",+ baseRefName: "main",+ headRefName: "dev",+ state: "OPEN",+ isCrossRepository: false,+ headRepository: { nameWithOwner: "contributor/demo" },+ headRepositoryOwner: { login: "contributor" },+ };+ const { manager, ghCalls } = yield* makeManager({+ ghScenario: {+ prListByHeadSelector: {+ dev: encodeCliJson([+ sameRepositoryPr,+ {+ ...sameRepositoryPr,+ number: 4,+ title: "Fork PR",+ url: "https://github.com/acme/demo/pull/4",+ isCrossRepository: true,+ },+ ]),+ },+ },+ });++ const result = yield* runStackedAction(manager, {+ cwd: repoDir,+ action: "commit_push_pr",+ });++ expect(result.pr.status).toBe("opened_existing");+ expect(result.pr.number).toBe(4);+ expect(ghCalls.some((call) => call.startsWith("pr create "))).toBe(false);+ }),+ 12_000,+ );+it.effect("returns the correct existing PR when a slash remote checks out to a synthetic local alias",() =>@@ -4545,6 +4891,13 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {yield* runGit(repoDir, ["checkout", "-b", "statemachine"]);const forkDir = yield* createBareRemote();yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);+ // Origin is the base repository; a lone remote would be the base itself.+ yield* runGit(repoDir, [+ "remote",+ "add",+ "origin",+ "[email protected]:pingdotgg/codething-mvp.git",+ ]);yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);@@ -4611,6 +4964,13 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {yield* runGit(repoDir, ["checkout", "-b", "statemachine"]);const forkDir = yield* createBareRemote();yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);+ // Origin is the base repository; a lone remote would be the base itself.+ yield* runGit(repoDir, [+ "remote",+ "add",+ "origin",+ "[email protected]:pingdotgg/codething-mvp.git",+ ]);yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);@@ -4672,6 +5032,13 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {yield* runGit(repoDir, ["checkout", "-b", "statemachine"]);const forkDir = yield* createBareRemote();yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);+ // Origin is the base repository; a lone remote would be the base itself.+ yield* runGit(repoDir, [+ "remote",+ "add",+ "origin",+ "[email protected]:pingdotgg/codething-mvp.git",+ ]);yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);yield* runGit(repoDir, ["config",@@ -5159,6 +5526,13 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {yield* initRepo(repoDir);const forkDir = yield* createBareRemote();yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);+ // Origin is the base repository; a lone remote would be the base itself.+ yield* runGit(repoDir, [+ "remote",+ "add",+ "origin",+ "[email protected]:pingdotgg/codething-mvp.git",+ ]);yield* runGit(repoDir, ["checkout", "-b", "statemachine"]);NodeFS.writeFileSync(NodePath.join(repoDir, "changes.txt"), "change\n");yield* runGit(repoDir, ["add", "changes.txt"]);diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.tsindex fdc2bf2f88b..6167ee6c1a8 100644--- a/apps/server/src/git/GitManager.ts+++ b/apps/server/src/git/GitManager.ts@@ -62,6 +62,11 @@ import {type ChangeRequestTerminology,} from "@t3tools/shared/sourceControl";import { parseChangeRequestUrl } from "@t3tools/shared/changeRequestUrl";+import * as HostProcess from "@t3tools/shared/HostProcess";+import {+ parseGitHubRepositorySelector,+ resolveGitHubRepository,+} from "@t3tools/source-control-github/server/gitHubRepositoryResolution";import {normalizeThreadPullRequestKey,threadPullRequestKeyOf,@@ -616,6 +621,11 @@ function headBranchProbe();}+/** A URL's host as `new URL` reads it: lowercased, any non-default port kept, `:443` dropped. */+function urlHost(url: string): string | null {+ return URL.canParse(url) ? new URL(url).host : null;+}+function appendUnique(values: string[], next: string | null | undefined): void {const trimmed = next?.trim() ?? "";if (trimmed.length === 0 || values.includes(trimmed)) {@@ -703,6 +713,7 @@ export const make = Effect.gen(function* () {const crypto = yield* Crypto.Crypto;const fileSystem = yield* FileSystem.FileSystem;const path = yield* Path.Path;+ const environment = yield* HostProcess.Environment;const sourceControlProvider = (cwd: string) => sourceControlProviders.resolve({ cwd });const serverSettingsService = yield* ServerSettings.ServerSettingsService;@@ -1373,6 +1384,41 @@ export const make = Effect.gen(function* () {const readConfigValueNullable = (cwd: string, key: string) =>gitCore.readConfigValue(cwd, key).pipe(Effect.orElseSucceed(() => null));+ // Whether the GitHub provider creates PRs in the only remote. It picks GH_REPO when that+ // parses, else what resolveGitHubRepository makes of the remote and its gh-resolved mark from+ // `gh repo set-default`, given the host the provider's context gets from the remote URL. An+ // HTTPS remote keeps a non-default port there, and the provider then ignores the mark. With no+ // answer at all, the provider falls back to the remote itself.+ const targetsOnlyRemote = Effect.fn("targetsOnlyRemote")(function* (+ cwd: string,+ remoteName: string,+ remote: { readonly remoteUrl: string | null; readonly repositoryNameWithOwner: string | null },+ ) {+ const baseUrl =+ remote.remoteUrl === null+ ? undefined+ : detectSourceControlProviderFromGitRemoteUrl(remote.remoteUrl)?.baseUrl;+ const host = baseUrl === undefined ? null : urlHost(baseUrl);+ const repository = remote.repositoryNameWithOwner?.toLowerCase();+ const fromEnvironment = parseGitHubRepositorySelector(environment.GH_REPO ?? "", host ?? "");+ if (fromEnvironment !== null) {+ const { host: targetHost, owner, name } = fromEnvironment;+ return (+ host !== null &&+ urlHost(`https://${targetHost}`) === host &&+ `${owner}/${name}`.toLowerCase() === repository+ );+ }+ const mark = yield* readConfigValueNullable(cwd, `remote.${remoteName}.gh-resolved`);+ const { locator } = resolveGitHubRepository({+ remotes: remote.remoteUrl === null ? "" : `${remoteName}\t${remote.remoteUrl} (fetch)`,+ resolved: mark === null ? "" : `remote.${remoteName}.gh-resolved ${mark}`,+ hostHint: host ?? undefined,+ defaultHost: host ?? "github.com",+ });+ return locator === null || `${locator.owner}/${locator.name}`.toLowerCase() === repository;+ });+const resolveHostingProvider = Effect.fn("resolveHostingProvider")(function* (cwd: string,branch: string | null,@@ -1402,6 +1448,7 @@ export const make = Effect.gen(function* () {) {if (!remoteName) {return {+ remoteUrl: null,remoteUrlKey: null,repositoryNameWithOwner: null,ownerLogin: null,@@ -1425,6 +1472,7 @@ export const make = Effect.gen(function* () {repositoryNameWithOwner = parseRepositoryNameWithOwnerFromRemoteUrl(remoteUrl, provider);}return {+ remoteUrl,remoteUrlKey: remoteUrl ? normalizeGitRemoteUrl(remoteUrl) : null,repositoryNameWithOwner,ownerLogin: parseRepositoryOwnerLogin(repositoryNameWithOwner),@@ -1463,14 +1511,35 @@ export const make = Effect.gen(function* () {remoteName,);+ // With no origin to compare against, the only remote is the repository gh targets+ // unless GH_REPO or `gh repo set-default` (gh-resolved) names another, so a branch on it+ // is not a fork. With several remotes, or with that other target, it may still be a fork.+ const isOnlyRemote =+ remoteName !== null &&+ remoteName !== "origin" &&+ originRepository.remoteUrlKey === null &&+ (yield* gitCore+ .execute({+ operation: "GitManager.resolveBranchHeadContext.remotes",+ cwd,+ args: ["remote"],+ timeoutMs: 5_000,+ })+ .pipe(+ Effect.map(+ (result) => result.stdout.split("\n").filter((name) => name.trim().length > 0).length,+ ),+ Effect.orElseSucceed(() => 0),+ )) === 1 &&+ (yield* targetsOnlyRemote(cwd, remoteName, remoteRepository));+ const isForeignRemote = remoteName !== null && remoteName !== "origin" && !isOnlyRemote;+const isCrossRepository =remoteRepository.repositoryNameWithOwner !== null &&originRepository.repositoryNameWithOwner !== null? remoteRepository.repositoryNameWithOwner.toLowerCase() !==originRepository.repositoryNameWithOwner.toLowerCase()- : remoteName !== null &&- remoteName !== "origin" &&- remoteRepository.repositoryNameWithOwner !== null;+ : isForeignRemote && remoteRepository.repositoryNameWithOwner !== null;const ownerHeadSelector =remoteRepository.ownerLogin && headBranch.length > 0@@ -1478,8 +1547,7 @@ export const make = Effect.gen(function* () {: null;const remoteAliasHeadSelector =remoteName && headBranch.length > 0 ? `${remoteName}:${headBranch}` : null;- const shouldProbeRemoteOwnedSelectors =- isCrossRepository || (remoteName !== null && remoteName !== "origin");+ const shouldProbeRemoteOwnedSelectors = isCrossRepository || isForeignRemote;const headSelectors: string[] = [];if (isCrossRepository && shouldProbeRemoteOwnedSelectors) {