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

53 lines1,879 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.

API and MCP server, Rust identity service, registration, site redesign1import { env } from "cloudflare:workers";
2
3import type { Route } from "./+types/commits";
4import { Avatar, EmptyState, TimeAgo } from "../../components/ui";
5import { getViewer, unwrap } from "../../lib/session.server";
6
7const PAGE_SIZE = 50;
8
9export function meta({ params }: Route.MetaArgs) {
10 return [{ title: `Commits · ${params.owner}/${params.repo} · g1t` }];
11}
12
13export async function loader({ params, context }: Route.LoaderArgs) {
14 const path = { namespace: params.owner, name: params.repo };
15 return {
16 commits: unwrap(
17 await env.REPOS.log(path, getViewer(context), null, PAGE_SIZE),
18 ),
19 };
20}
21
22export default function Commits({ loaderData }: Route.ComponentProps) {
23 const { commits } = loaderData;
24 if (commits.length === 0) {
25 return <EmptyState title="No commits yet" />;
26 }
27 return (
28 <ol className="divide-y divide-line overflow-hidden rounded-xl border border-line">
29 {commits.map((commit) => {
30 const [subject, ...body] = commit.message.split("\n");
31 return (
32 <li key={commit.hash} className="flex items-start gap-3 px-4 py-3">
33 <Avatar name={commit.author.name} size={24} />
34 <div className="min-w-0 grow">
35 <p className="truncate font-medium">{subject}</p>
36 {body.join("\n").trim() && (
37 <p className="mt-1 line-clamp-2 text-sm whitespace-pre-line text-muted">
38 {body.join("\n").trim()}
39 </p>
40 )}
41 <p className="mt-1 text-xs text-faint">
42 {commit.author.name} committed <TimeAgo at={commit.authoredAt} />
43 </p>
44 </div>
45 <span className="shrink-0 rounded-md border border-line px-2 py-0.5 font-mono text-xs text-muted">
46 {commit.hash.slice(0, 7)}
47 </span>
48 </li>
49 );
50 })}
51 </ol>
52 );
53}