g1t/apps/web/app/routes/repo/tree.tsx

28 lines1,347 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Initial g1t: services, event bus, intents and attempts1import type { Route } from "./+types/tree";
Social cards for every page: og.g1t.sh2import { page } from "../../lib/meta";
Initial g1t: services, event bus, intents and attempts3import { TreeView } from "../../components/repo-view";
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look4import { redirectIfBranchRenamed } from "../../lib/branch-redirect.server";
Rust repos service with shipping; pull requests kept in the model5import { repos } from "../../lib/services.server";
Initial g1t: services, event bus, intents and attempts6import { getViewer, unwrap } from "../../lib/session.server";
7
Social cards for every page: og.g1t.sh8export function meta({ params, ...args }: Route.MetaArgs) {
Initial g1t: services, event bus, intents and attempts9 const path = params["*"] ? `${params["*"]} · ` : "";
Social cards for every page: og.g1t.sh10 return page(args, { title: `${path}${params.owner}/${params.repo} · g1t` });
Initial g1t: services, event bus, intents and attempts11}
12
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look13export async function loader({ params, context, request }: Route.LoaderArgs) {
Initial g1t: services, event bus, intents and attempts14 const path = { namespace: params.owner, name: params.repo };
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look15 const viewer = getViewer(context);
The code page reads like a forge: a branch menu, search and a Code button above the files16 const [tree, branches] = await Promise.all([
17 repos.tree(path, viewer, params.ref, params["*"] ?? ""),
18 // For the branch menu; the page still shows without it.
19 repos.branches(path, viewer).catch(() => null),
20 ]);
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look21 // A branch that was renamed: the same folder on its new name.
22 if (!tree.ok && tree.error.code === "not_found") await redirectIfBranchRenamed(request, path, viewer, params.ref);
The code page reads like a forge: a branch menu, search and a Code button above the files23 return { tree: unwrap(tree), branches: branches?.ok ? branches.value : null };
Initial g1t: services, event bus, intents and attempts24}
25
26export default function Tree({ loaderData }: Route.ComponentProps) {
The code page reads like a forge: a branch menu, search and a Code button above the files27 return <TreeView tree={loaderData.tree} branches={loaderData.branches} />;
Initial g1t: services, event bus, intents and attempts28}