Recipe: git log

The fromGitLog helper parses a tab-delimited git log stream into Commit[]. Use the exported GIT_LOG_FORMAT constant to keep the format string aligned with the parser.

1. Shell command

git log --all --pretty="%H%x09%P%x09%ct%x09%an%x09%ae%x09%s"

2. Parse + render

import { fromGitLog, GIT_LOG_FORMAT } from "@/components/git-graph/lib/from-git-log";
import { execSync } from "node:child_process";

const text = execSync(`git log --all --pretty="${GIT_LOG_FORMAT}"`, { encoding: "utf8" });
const commits = fromGitLog(text);

Live (with the sample fixture)

Format reference

The format string maps to: %H (sha), %P (parents, space-separated), %ct (commit time, unix seconds), %an/%ae (author name/email), %s (subject). Tabs separate fields; newlines separate commits.