import { cn } from "~/utils/cn"; import { TONE_BADGE } from "~/ui/tones"; import type { CommitSignature } from "~/hooks/use-commit-signatures"; const REASONS: Record = { unknown_key: "The signing key is not registered to any gitfor account.", bad_signature: "The signature does not match the commit contents.", email_mismatch: "The committer email does not match the key owner's account email.", unsupported: "The signature format or algorithm is not supported.", malformed: "The signature could not be parsed.", signer_disabled: "The signing key belongs to a disabled account.", }; export function SignatureBadge({ signature, className, }: { signature: CommitSignature | undefined; className?: string; }) { if (!signature || signature.reason === "unsigned") return null; const verified = signature.verified; const title = verified ? `Signed with ${signature.kind === "ssh" ? "SSH" : "GPG"} key ${signature.keyFingerprint ?? ""} by ${signature.signer ?? "unknown"}` : (REASONS[signature.reason] ?? "Unverified signature"); return ( {verified ? "Verified" : "Unverified"} ); }