TypeScript
fix(shared): local-path remotes no longer crash legacy PR link projection (#13463)
Pujitha Paladugu38f3c62304bf
diff --git a/packages/shared/src/threadPullRequests.test.ts b/packages/shared/src/threadPullRequests.test.tsindex 4844df8f778..a7042a7c882 100644--- a/packages/shared/src/threadPullRequests.test.ts+++ b/packages/shared/src/threadPullRequests.test.ts@@ -242,6 +242,18 @@ describe("legacyLinkedPullRequestOf", () => {it("does not guess when the project identity is unavailable", () => {expect(legacyLinkedPullRequestOf([link(7)], "project-1" as never, null)).toBeNull();});+ it("does not route links for a local-path remote with no host or provider", () => {+ const localIdentity = {+ canonicalKey: "/tmp/r/remote",+ displayName: "remote",+ locator: {+ source: "git-remote" as const,+ remoteName: "origin",+ remoteUrl: "/tmp/r/remote.git",+ },+ };+ expect(legacyLinkedPullRequestOf([link(7)], "project-1" as never, localIdentity)).toBeNull();+ });});describe("resolveThreadPullRequestChains", () => {diff --git a/packages/shared/src/threadPullRequests.ts b/packages/shared/src/threadPullRequests.tsindex e747c151bd1..15b5451adf0 100644--- a/packages/shared/src/threadPullRequests.ts+++ b/packages/shared/src/threadPullRequests.ts@@ -157,7 +157,9 @@ export function legacyLinkedPullRequestOf(identity: RepositoryIdentity | null | undefined,): ThreadLinkedPullRequest | null {if (!identity) return null;+ // A local-path remote has no host segment and no provider, so there is no host to match.const host = pullRequestHostOf(identity, identity.provider as SourceControlProviderKind);+ if (typeof host !== "string") return null;const repository = sourceControlRepositorySelector(identity);if (repository === null) return null;const azureKey =