Improve figure

This commit is contained in:
Martin Vuk 2025-12-09 04:24:09 +01:00
parent 191f5c4bd3
commit 9831b0b5b3

View file

@ -1,24 +1,41 @@
#set text(lang: "sl") #set text(lang: "sl")
#set page("a4", margin: 5mm)
#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge #import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
#import fletcher.shapes: house, chevron, pill, hexagon #import fletcher.shapes: house, chevron, pill, hexagon
#let commit-node(coord, hash, ..args) = node(coord, raw(hash), shape: pill, fill: orange.lighten(10%), stroke: none, ..args)
#let commit-object(coord, hash, name, ..args) = node(coord, align(left, [#text(size: 8pt, gray.darken(50%), raw(hash))\ #name]), corner-radius: 7pt, fill: orange.lighten(10%), stroke: none, ..args)
#diagram(debug: 1, node-stroke: 2pt, edge-stroke: 1pt, #diagram(debug: 1, node-stroke: 2pt, edge-stroke: 1pt,
{ {
let thin = 0.5pt;
let thindashed = (thickness: thin, dash: "dashed");
let store = (1, 7) let store = (1, 7)
let (A, B, C, D, E, F, G) = ((2, 6), (2, 5), (2, 4), (2, 3), (2, 2), (2, 1), (2, 0)) let (A, B, C, D, E, F, G) = ((2, 6), (2, 5), (2, 4), (2, 3), (2, 2), (2, 1), (2, 0))
let (B1, B2) = ((3, 4.5), (3, 3.5)) let (B1, B2) = ((3, 4.5), (3, 3.5))
let (E1, E2, E3) = ((3, 1.5), (3, 0.5), (3, -0.5)) let (E1, E2, E3) = ((3, 1.5), (3, 0.5), (3, -0.5))
let (Br1, Br2) = ((1, G.at(1)), (2.5, E2.at(1))) let (Br1, Br2) = ((G.at(0)-0.5, G.at(1)), (E2.at(0)-0.5, E2.at(1)))
let (T1, T2) = ((1, E.at(1)), (1, B.at(1))) let (T1, T2) = ((E.at(0)-0.5, E.at(1)), (B.at(0)-0.5, B.at(1)))
let refs = (3, 7) let refs = (3, 8)
node(store, [Content addressable object store], width: 3cm) let tags = (0.5, 3)
node(A, [A 16f299], shape: pill, name: <A>) let commit = (3.7, 2.5)
let branches = (1.2, -1)
let stage =(3.7, -1)
let mc = (2.5, D.at(1)-0.5)
commit-object(store, "e264a1", [second commit])
commit-object((store.at(0), store.at(1)+0.3), "16f29", [first commit], width: 2.8cm)
node(store, [Content addressable object store], width: 3cm, stroke: none,
enclose:((store.at(0), store.at(1)), (store.at(0)+1, store.at(1)+2)))
//node(A, [A 16f299], shape: pill, name: <A>)
commit-node(A, "A 16f299")
node(B, [B 16f299], shape: pill) node(B, [B 16f299], shape: pill)
node(C, [C 16f299], shape: pill) node(C, [C 16f299], shape: pill)
node(D, [D 16f299], shape: pill) node(D, [D 16f299], shape: pill)
node(E, [E 16f299], shape: pill) node(E, [E 16f299], shape: pill)
node(F, [F 16f299], shape: pill) node(F, [F 16f299], shape: pill)
node(G, [16f299], shape: pill) node(G, [16f299], shape: pill)
// merge commit
node(mc, [Merge commit\ #text(size: 8pt)[commit with two parents]], stroke: thin, corner-radius: 10pt)
// merged branch // merged branch
node(B1, [B1 16f299], shape: pill) node(B1, [B1 16f299], shape: pill)
node(B2, [B2 16f299], shape: pill) node(B2, [B2 16f299], shape: pill)
@ -38,13 +55,13 @@
`feature-1`: `8dd6d4b...`\ `feature-1`: `8dd6d4b...`\
`hotfix`: `8dd6d4b...`]) `hotfix`: `8dd6d4b...`])
) )
let branches = (2, -2) node(branches, [#text(stroke: purple.darken(50%))[BRANCH]\ #text[reference that moves when commiting canges]],
node(branches, [#text(stroke: purple.darken(50%))[BRANCH]\ reference that moves when commiting canges], stroke: thin, corner-radius: 10pt, inset: 0pt, width: 1cm, enclose: (
stroke: 0.5pt, corner-radius: 10pt, inset: 0pt, width: 1cm, enclose: ((2, -2), (3, -2))) (branches.at(0)-0.5, branches.at(1)),
let tags = (0, 3.5) (branches.at(0)+0.5, branches.at(1))))
node(tags, [#text(stroke: green.darken(50%))[TAG]\ reference that don't move], node(tags, [#text(stroke: green.darken(50%))[TAG]\ reference that don't move],
stroke: 0.5pt, corner-radius: 10pt, inset: 0pt, width: 1cm, enclose: ((0, 3.5), (1, 4.5))) stroke: thin, corner-radius: 10pt, inset: 0pt, width: 1cm, enclose: ((tags.at(0)-0.5, tags.at(1)), (tags.at(0)+1, tags.at(1))))
let commit = (3.5, 2.5) node(stage, [*Staging area*\ #text(size: 8pt)[filesystem snapshot that will be commited in the next commit]], stroke: thindashed, corner-radius: 10pt, width: 3cm)
node(commit, [ node(commit, [
*COMMIT*\ snapshot of filesystem tree in object store\ *COMMIT*\ snapshot of filesystem tree in object store\
#rect[ #rect[
@ -56,11 +73,15 @@ committer MV <mv...
Add bar.txt Add bar.txt
```] ```]
], width:5cm, stroke: 0.5pt, corner-radius: 10pt) ], width:5cm, stroke: thin, corner-radius: 10pt)
node((2, 7), [*Version history*\ node((G.at(0)+0.4, G.at(1) - 0.3), [*Version history*\
#text(size: 0.6em)[ #text(size: 8pt)[
Commits are nodes in _Directed Acyclic Graph (DAG)_ that describes version history Commits are nodes in _Directed Acyclic Graph (DAG)_ that describes version history
]], width: 4cm) ]], stroke:none, width: 5cm)
node(A, snap: false, enclose: (A, E3), stroke: thindashed, width: 3cm)
let ic = (A.at(0)-0.6, A.at(1)+0.2);
node(ic, [Initial commit], shape: pill, stroke: thin)
edge(ic, A, stroke: thin)
// history // history
edge(B, A, "->") edge(B, A, "->")
edge(C, B, "->") edge(C, B, "->")
@ -69,7 +90,7 @@ Add bar.txt
edge(F, E, "->") edge(F, E, "->")
edge(G, F, "->") edge(G, F, "->")
// merged branch // merged branch
edge(B1, B, "->", layer: 1) edge(B1, B, "->", layer: 1, label: [parent of], label-angle: auto)
edge(B2, B1, "->") edge(B2, B1, "->")
edge(D, B2, "->") edge(D, B2, "->")
// unmerged branch // unmerged branch
@ -81,10 +102,13 @@ Add bar.txt
edge(Br2, E2) edge(Br2, E2)
edge(T1, E) edge(T1, E)
edge(T2, B) edge(T2, B)
edge(Br1, branches, stroke: 0.5pt) edge(Br1, branches, stroke: thin)
edge(Br2, branches, stroke: 0.5pt) edge(Br2, branches, stroke: thin)
edge(T1, tags, stroke: 0.5pt) edge(T1, tags, stroke: thin)
edge(T2, tags, stroke: 0.5pt) edge(T2, tags, stroke: thin)
edge(commit, E, stroke: 0.5pt) edge(commit, E, stroke: thin)
edge(stage, E3, stroke: thindashed)
edge((-0.5, A.at(1)), (-0.5, G.at(1)), "->", label: [time], label-side: left, label-angle: 90deg)
edge(mc, D, stroke: thin)
} }
) )