// Commit detail page (/:repo/commit/:hash). Shows commit metadata, full
// message, parent links, and changed files with lazy diffs.
import { gql, useQuery } from "@apollo/client";
import { format } from "date-fns";
import { ArrowLeft, GitCommit } from "lucide-react";
import { Link, useParams, useNavigate } from "react-router-dom";
import { FileDiffView } from "@/components/code/FileDiffView";
import { Skeleton } from "@/components/ui/skeleton";
import { useRepo } from "@/lib/repo";
const COMMIT_QUERY = gql`
query CommitPageDetail($repo: String, $hash: String!) {
repository(ref: $repo) {
commit(hash: $hash) {
hash
shortHash
message
fullMessage
authorName
authorEmail
date
parents
files {
nodes {
path
oldPath
status
}
}
}
}
}
`;
export function CommitPage() {
const { hash } = useParams<{ hash: string }>();
const navigate = useNavigate();
const repo = useRepo();
const { data, loading, error } = useQuery(COMMIT_QUERY, {
variables: { repo, hash },
skip: !hash,
});
if (loading) return
{commit.fullMessage.split("\n").slice(1).join("\n").trim()}
)}
{commit.hash}
{commit.parents.map((p: string) => (
parent{" "}
{p.slice(0, 7)}
))}
No file changes.
)} {files.map((file: { path: string; oldPath?: string | null; status: string }) => (