Skip to content
45 linesCodeBlameRaw

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";
About: license, languages, contributors, stars, releases and activity beside the files5import { aboutFor } from "../../lib/about.server";
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them6import { lastCommitsFor } from "../../lib/last-commits.server";
Rust repos service with shipping; pull requests kept in the model7import { repos } from "../../lib/services.server";
Initial g1t: services, event bus, intents and attempts8import { getViewer, unwrap } from "../../lib/session.server";
About: license, languages, contributors, stars, releases and activity beside the files9import { useProject } from "./layout";
Initial g1t: services, event bus, intents and attempts10
Social cards for every page: og.g1t.sh11export function meta({ params, ...args }: Route.MetaArgs) {
Initial g1t: services, event bus, intents and attempts12 const path = params["*"] ? `${params["*"]} · ` : "";
Social cards for every page: og.g1t.sh13 return page(args, { title: `${path}${params.owner}/${params.repo} · g1t` });
Initial g1t: services, event bus, intents and attempts14}
15
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look16export async function loader({ params, context, request }: Route.LoaderArgs) {
Initial g1t: services, event bus, intents and attempts17 const path = { namespace: params.owner, name: params.repo };
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look18 const viewer = getViewer(context);
The code page reads like a forge: a branch menu, search and a Code button above the files19 const [tree, branches] = await Promise.all([
20 repos.tree(path, viewer, params.ref, params["*"] ?? ""),
21 // For the branch menu; the page still shows without it.
22 repos.branches(path, viewer).catch(() => null),
23 ]);
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look24 // A branch that was renamed: the same folder on its new name.
25 if (!tree.ok && tree.error.code === "not_found") await redirectIfBranchRenamed(request, path, viewer, params.ref);
Branches and Tags pages, each file's last commit, and the branch menu on files26 // Each entry's last commit walks history: streamed in after the list.
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them27 const lastCommits = lastCommitsFor(path, viewer, params.ref, params["*"] ?? "");
About: license, languages, contributors, stars, releases and activity beside the files28 const value = unwrap(tree);
29 // At the root, the About beside the files, streamed in after them.
30 const about = value.head && !value.path ? aboutFor(path, viewer, value.repo.id) : null;
31 return { tree: value, branches: branches?.ok ? branches.value : null, lastCommits, about };
Initial g1t: services, event bus, intents and attempts32}
33
34export default function Tree({ loaderData }: Route.ComponentProps) {
About: license, languages, contributors, stars, releases and activity beside the files35 const project = useProject();
36 return (
37 <TreeView
38 tree={loaderData.tree}
39 branches={loaderData.branches}
40 lastCommits={loaderData.lastCommits}
41 about={loaderData.about}
42 canPush={Boolean(project?.access.can.push)}
43 />
44 );
Initial g1t: services, event bus, intents and attempts45}