{"modulePath":"github.com/CommitBrief/commitbrief","version":"v1.23.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package graph\n\nPackage graph lays a commit list out onto terminal columns (\"lanes\") so a renderer can draw the DAG the way \\`git log --graph\\` does (ADR-0037).\n\nIt is deliberately git-free and render-free: the input is an ordered commit list with parent hashes, the output is one Row per commit carrying the glyph for every lane column. That keeps the tricky part — lane bookkeeping — a pure function that can be tested against hand-written DAGs, and leaves colour, unicode-vs-ASCII, and width clipping entirely to the caller.\n\n## Types\n\n```go\ntype Commit struct {\n\tHash    string\n\tParents []string\n}\n```\nCommit is the minimal shape Layout needs. It mirrors the fields of git.CommitMeta that matter for topology, so callers can adapt without this package importing internal/git (keeping it a leaf, like internal/tokens).\n\n```go\ntype Glyph uint8\n```\nGlyph is what occupies one lane column on one row.\n\n```go\nconst (\n\t// GlyphEmpty is an unused column.\n\tGlyphEmpty Glyph = iota\n\t// GlyphCommit is the commit's own marker; exactly one per row.\n\tGlyphCommit\n\t// GlyphVertical is a lane passing straight through this row.\n\tGlyphVertical\n\t// GlyphFork is a lane branching out to the right (a second parent leaving\n\t// the commit's lane).\n\tGlyphFork\n\t// GlyphMerge is a lane folding back in to the left (a lane whose commit\n\t// has been reached and that now rejoins).\n\tGlyphMerge\n)\n```\n\n```go\ntype Row struct {\n\tCommit  Commit\n\tLane    int\n\tMatched bool\n\tCells   []Glyph\n}\n```\nRow is one rendered line: the commit, its lane index, and the glyph for each lane column. Cells is exactly Width() wide.\n\n```go\nfunc Layout(commits []Commit, matched map[string]bool) []Row\n```\nLayout assigns each commit a lane and produces one Row per commit, in input order (which the caller is expected to have sorted newest-first, as git log does).\n\nThe algorithm is the standard one: \\`lanes\\` holds, per column, the hash that column is currently waiting to draw. When a commit is reached, it takes the leftmost lane already waiting for it; its first parent inherits that lane and every additional parent claims a new one (a fork). Any \\*other\\* lane also waiting for this commit is released — that is a merge point, where two lines of development converge.\n\nmatched marks which commits satisfied the caller's filter; a nil map means \"everything matches\", which is what an unfiltered run wants.\n\nCommits whose parents are outside the input set (a truncated walk, or a range that starts mid-history) simply close their lane — the graph shows the boundary rather than inventing edges to commits it was never given.\n\n```go\nfunc (r Row) Width() int\n```\nWidth returns how many lane columns this row occupies.\n\n","path":"github.com/CommitBrief/commitbrief/internal/graph","name":"graph","synopsis":"Package graph lays a commit list out onto terminal columns (\"lanes\") so a renderer can draw the DAG the way `git log --graph` does (ADR-0037).","isRedistributable":true}
