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