Documentation
¶
Overview ¶
Package commitgraph lays out and draws a Git history's revision graph: the lanes commits sit in and the lines joining them to their parents. It has no look: the app gives Graph its colors and builds the rows around it.
Index ¶
Constants ¶
const ( // RowHeight is a row's height, which the lines span. RowHeight core.Points = 26 // LaneWidth is a column's width. LaneWidth core.Points = 12 )
The graph's size by default, shared so the rows of a list line up.
const MaxLines = 64
MaxLines bounds a graph's open lines, so a history with very many open branches cannot widen it without limit.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Commit ¶
type Commit struct {
Hash string
// Parents are the commit's parents' hashes, the first parent first.
Parents []string
}
Commit is what the graph knows of a commit. A history lists its commits newest first with each after its children, as `git log --date-order` does.
type Graph ¶
type Graph struct {
History *History
// Item is the row's commit, read as a signal.
Item func() Item
// Height is the row's, RowHeight when 0, and Lane a column's width,
// LaneWidth when 0.
Height, Lane core.Points
// Color returns a line's color, the text's when nil.
Color func(line int) core.Color
// Class, Style and StyleFunc are the graph's.
Class string
Style core.Style
StyleFunc func() core.Style
// MergeClass, MergeStyle and MergeStyleFunc are the merge button's,
// such as its hover.
MergeClass string
MergeStyle core.Style
MergeStyleFunc func() core.Style
}
Graph draws one commit's row of the revision graph: lines cross the row and curve into and out of the commit, a ring in its line's color. Its width is its own row's columns, so a busy stretch of history does not push every subject away from its graph; give each row of a list one Graph and no gap between them, so the lines meet.
A commit the History knows as a merge is a disc with a chevron, pointing down while expanded and right, inside a ring, while collapsed, and a button that toggles it. What the graph cuts out of itself shows the row behind it, selected or not.
type History ¶
type History struct {
// contains filtered or unexported fields
}
History is a list of commits with its merges collapsed or expanded, and the graph of the commits that leaves shown. The app makes it with NewHistory and lists its rows with At.
func NewHistory ¶
NewHistory returns the history of commits, which it reads as signals, with every merge expanded. With a selection, one a collapsing merge hides moves to the merge.
func (*History) At ¶
At returns the i-th shown commit, the zero Item past the end as a list's cell may read it while the history shrinks.
type Item ¶
type Item struct {
Index int
Hash string
Row Row
// Merge reports that the commit has commits to collapse.
Merge bool
}
Item is a shown commit of a History: its index in the history's commits and its graph.
type Line ¶
type Line struct {
ID, Top, Column, Bottom int
}
Line is one line crossing a commit's row: it enters the row's top edge in column Top, passes the row's middle in Column and leaves the bottom edge in Bottom. -1 means the line does not touch that edge, so it ends at the commit (no Bottom) or starts from it (no Top). ID keeps its color.
type Row ¶
Row is the graph of one commit: the lines crossing its row, the column of the commit itself and of the line it belongs to, -1 for a commit past MaxLines, which shows no node, and the number of columns the row draws in.
func Layout ¶
Layout lays out the revision graph of commits and returns a row per commit. It keeps a line open for each parent still to come and numbers a new line by the column it opens in, so a branch takes that column's color and keeps it while open, and a merge folds it back into its first parent.