Skip to content
TypeScript

fix(clients): prompt links find projects cloned from git.cafe (#26042)

Julius Marminge02329327c64f
diff --git a/packages/client-runtime/src/promptLinks.test.ts b/packages/client-runtime/src/promptLinks.test.ts
index 213392f6c61..12a73ddf915 100644
--- a/packages/client-runtime/src/promptLinks.test.ts
+++ b/packages/client-runtime/src/promptLinks.test.ts
@@ -39,6 +39,19 @@ describe("findPromptLinkProjects", () => {
expect(ids("me", "t3code")).toEqual(["fork"]);
expect(ids("gitlab", "x")).toEqual([]);
});
+
+ it("matches a checkout of the repository's GitCafe mirror", () => {
+ const projects = [
+ { id: "gitcafe", repositoryIdentity: identity("git.cafe/pingdotgg/t3code") },
+ { id: "staging", repositoryIdentity: identity("staging.git.cafe/pingdotgg/t3code") },
+ { id: "gitlab", repositoryIdentity: identity("gitlab.com/pingdotgg/t3code") },
+ ];
+ expect(
+ findPromptLinkProjects(projects, { owner: "pingdotgg", name: "t3code" }).map(
+ (project) => project.id,
+ ),
+ ).toEqual(["gitcafe", "staging"]);
+ });
});
describe("pickPromptLinkPullRequestThread", () => {
diff --git a/packages/client-runtime/src/promptLinks.ts b/packages/client-runtime/src/promptLinks.ts
index 135b1c13f11..2c72280745b 100644
--- a/packages/client-runtime/src/promptLinks.ts
+++ b/packages/client-runtime/src/promptLinks.ts
@@ -18,8 +18,9 @@ import {
visibleThreadPullRequests,
} from "./threadPullRequests.ts";
-const repositoryKey = (repository: PromptLinkRepository) =>
- `github.com/${repository.owner}/${repository.name}`.toLowerCase();
+// A link's `owner/name` is GitHub's. GitCafe syncs a repository two-way with GitHub under the
+// same path, so a checkout cloned from git.cafe counts as the linked repository.
+const PROMPT_LINK_REPOSITORY_HOSTS = ["github.com", "git.cafe", "staging.git.cafe"];
/**
* The repository's projects in the order given. Callers pass projects most recently active
@@ -28,11 +29,12 @@ const repositoryKey = (repository: PromptLinkRepository) =>
export function findPromptLinkProjects<
P extends { readonly repositoryIdentity?: RepositoryIdentity | null | undefined },
>(projects: ReadonlyArray<P>, repository: PromptLinkRepository): P[] {
- const key = repositoryKey(repository);
+ const path = `${repository.owner}/${repository.name}`.toLowerCase();
+ const keys = new Set(PROMPT_LINK_REPOSITORY_HOSTS.map((host) => `${host}/${path}`));
return projects.filter(
(project) =>
project.repositoryIdentity != null &&
- repositoryGroupingKeyOf(project.repositoryIdentity).toLowerCase() === key,
+ keys.has(repositoryGroupingKeyOf(project.repositoryIdentity).toLowerCase()),
);
}