// SPDX-FileCopyrightText: 2026 Progmasoft // SPDX-License-Identifier: AGPL-3.0-or-later import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { getGitMessages } from "@/lib/git-messages"; import { gitCommit, gitRepository } from "@/lib/git.server"; import { getLocale } from "@/lib/locale.server"; import { GitFrame, gitDate, gitHref } from "../../../GitFrame"; interface Props { params: Promise<{ repo: string; sha: string }>; } export async function generateMetadata({ params }: Props): Promise { const { repo, sha } = await params; return { title: `${sha.slice(0, 12)} · ${repo} · Progmasoft Git`, robots: { index: false, follow: true }, }; } /** The class of a line of a patch, for its color. */ function lineClass(line: string): string | undefined { if (line.startsWith("+++") || line.startsWith("---")) { return "pm-git-diff-file"; } if (line.startsWith("@@")) { return "pm-git-diff-hunk"; } if (line.startsWith("+")) { return "pm-git-diff-add"; } return line.startsWith("-") ? "pm-git-diff-remove" : undefined; } /** git.progmasoft.com//commit/: a commit and its changes. */ export default async function CommitPage({ params }: Props) { const { repo, sha } = await params; const locale = await getLocale(); const text = getGitMessages(locale); const repository = await gitRepository(repo); const commit = repository ? await gitCommit(repo, sha) : null; if (!repository || !commit) { notFound(); } const [subject, ...body] = commit.message.split("\n"); const lines = commit.diff.split("\n"); return (

{subject}

{body.join("\n").trim() ? (
{body.join("\n").trim()}
) : null}
{text.commit}
{commit.commit}
{text.author}
{commit.author} ·{" "}
{commit.committer !== commit.author ? ( <>
{text.committer}
{commit.committer}
) : null} {commit.parents.length > 0 ? ( <>
{text.parents}
{commit.parents.map((parent, index) => ( {index > 0 ? ", " : null} {parent.slice(0, 12)} ))}
) : null}

{text.files} {" "} ·{" "} {text.archive}

{text.changes}

          {lines.map((line, index) => (
            
              {line}
              {"\n"}
            
          ))}
        
{commit.isDiffTruncated ? (

{text.diffTruncated}

) : null}
); }