import { LayerCard } from "@refs/design-system"; import { WarningIcon } from "@refs/design-system/icons"; import { Avatar, formatDate } from "@refs/design-system"; import { narrative, parseDecisions } from "@refs/protocol"; import type { Route } from "./+types/repo-commit"; import { DecisionView } from "../components/decision-view"; import { DiffView } from "../components/diff-view"; import { found, refs, fullName } from "../lib/session"; export const meta: Route.MetaFunction = ({ loaderData, params }) => [{ title: loaderData ? `${loaderData.commit.message.split("\n")[0]} · ${fullName(params)} · refs` : `Commit · ${fullName(params)} · refs` }]; export async function loader({ params, context }: Route.LoaderArgs) { const repo = await found(refs(context).repo(fullName(params))); const commit = await found(repo.commit(params.hash)); return { repo: repo.summary.name, commit }; } export default function RepoCommit({ loaderData }: Route.ComponentProps) { const { repo, commit } = loaderData; const title = commit.message.split("\n")[0]; const story = narrative(commit.message); const { decisions, problems } = parseDecisions(commit.message, commit.hash); const parentLink = (hash: string) => ( {hash.slice(0, 7)} ); return (

{title}

{commit.author.name} committed {formatDate(commit.committedAt)} {commit.hash.slice(0, 7)} {commit.parents.length ? ( {commit.parents.length === 1 ? "parent" : "parents"} {commit.parents.map(parentLink)} ) : ( root commit )}
{story &&

{story}

}
{(decisions.length > 0 || problems.length > 0) && (
{decisions.length > 0 && (

{decisions.length} {decisions.length === 1 ? "decision" : "decisions"}

)} {problems.map((problem, index) => (

))} {decisions.map((record, index) => ( ))}
)}
); }