Open History to see the last commit
1import {
2 resolveChangeRequestLinkTarget,
3 type ChangeRequestLinkCapabilities,
4} from "@t3tools/client-runtime/change-request-links";
5import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
6import { EnvironmentId, ProjectId } from "@t3tools/contracts";
7
8/** The PullRequest route for a change request link from a project, or null for the browser. */
9export function nativePullRequestDestination(
10 url: string,
11 context: { environmentId: string; projectId: string } | null,
12 projects: ReadonlyArray<Pick<EnvironmentProject, "id" | "environmentId" | "repositoryIdentity">>,
13 capabilities: (environmentId: EnvironmentId) => ChangeRequestLinkCapabilities | undefined,
14) {
15 if (!context) return null;
16 const target = resolveChangeRequestLinkTarget({
17 url,
18 projects,
19 capabilities,
20 environmentId: EnvironmentId.make(context.environmentId),
21 projectId: ProjectId.make(context.projectId),
22 lendHostProject: true,
23 });
24 if (target === null) return null;
25 return {
26 environmentId: context.environmentId,
27 projectId: String(target.project.id),
28 repository: target.repository,
29 number: target.number,
30 ...(target.host === undefined ? {} : { host: target.host }),
31 };
32}