Data shape

GitGraph renders any array of Commit objects whose parents shas resolve within the array. The schema is intentionally minimal — most real Git data sources (CLI git log, GitHub REST, isomorphic-git) map to it in 5–10 lines.

Types

type Commit = {
  sha: string;                    // unique commit hash (any string; no length requirement)
  parents: string[];              // shas of parent commits, in primary-first order
  author: {
    name: string;
    email?: string;
    avatarUrl?: string;           // rendered as an <img> next to the message
  };
  message: string;                // headline only; trailing body lines are ignored
  timestamp: number | string;     // unix seconds (number) or ISO 8601 (string)
  refs?: Ref[];                   // optional decorations
};

type Ref = {
  name: string;                   // "main", "v1.2.0", "origin/main", etc.
  kind: "branch" | "tag" | "remote-branch";
  isHead?: boolean;               // adds a HEAD pointer next to the badge
};

Real-world example

[
  {
    "sha": "f6a1c20",
    "parents": ["a4b8d11", "c92e3b7"],
    "author": { "name": "Avery", "email": "avery@example.com" },
    "message": "Merge branch 'feature/login' into main",
    "timestamp": 1714512000,
    "refs": [{ "name": "main", "kind": "branch", "isHead": true }]
  }
]

Notes