Diagram: Git¶
Git diagrams visualize branches, commits, and merge commits on horizontal or vertical timelines.
Minimal example¶
import engrapha_notes as en
import engrapha_diagrams as ed
git = ed.GitDiagram(
width=400, height=150, caption="Fig 14: Git Flow"
)
git.commit("main", "c1: Initial commit")
git.branch("main", "feature/login")
git.commit("feature", "c2: Add login form")
git.commit("main", "c3: Hotfix typo")
git.merge("feature", "main", "c4: Merge feature/login")
en.add(git.as_flowable())
Commits¶
If label is empty, the commit is drawn but unlabeled.
Branches¶
Existing branches are tracked automatically; subsequent branch() calls with the same child are silently ignored.
Merges¶
The merge commits a dot on the target branch; the source branch is drawn as a curve back into it.
Colours¶
Branch colors are assigned automatically from a palette. Override manually by editing _branch_colors on the instance.
Commit spacing¶
Labels¶
If two commits land on the same branch consecutively, labels alternate up / down to avoid overlap.