Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

25 linesCodeBlameRaw
1/**
2 * A repository's issues, labels and milestones moved to its workspace's
3 * Work: old links are sent on
4 * (lib/work-items.ts `movedWorkPath` says where). An old issue's address
5 * is read as `#n` in the repository (lib/refs.ts): the work item its issue
6 * became, or a pull request. A work item belongs to the workspace, so these
7 * are open to every member, Code access or not (lib/workspace-nav.ts
8 * `codeGate`).
9 */
10import { data, redirect } from "react-router";
11
12import type { Route } from "./+types/moved-work";
13import { refPath } from "../../lib/refs.server";
14import { getViewer } from "../../lib/session.server";
15import { movedWorkPath } from "../../lib/work-items";
16
17export async function loader({ request, params, context }: Route.LoaderArgs) {
18 const url = new URL(request.url);
19 const to = movedWorkPath(url.pathname, url.search);
20 if (to == null) throw data(null, { status: 404 });
21 if (typeof to === "string") return redirect(to, 301);
22 const found = await refPath(getViewer(context), { repo: { namespace: params.owner.toLowerCase(), name: params.repo } }, to.resolve);
23 if (!found) throw data(null, { status: 404 });
24 return redirect(found, 301);
25}