Overzicht: lanelijnen met ronde hoeken en avatar als knoop
De commitgrafiek tekent één commit per regel, met verticale lanes en afgeronde 90-graden bochten. De avatar staat op de lane; de tekst begint rechts van de meest rechtse lane. De centrale kolom schuift iets naar rechts als de grafiek past, anders hangt hij rechts of blijft hij verborgen. De gekozen branch in de dropdown gloeit.
@@ -11,7 +11,7 @@ Het logo is de blauwe ster: [`assets/logo.svg`](assets/logo.svg).
11
11
## Wat het doet
12
12
13
13
- Repositories van een gebruiker of een groep, met bestanden, commits, branches, tags en releases.
14
- Op de project-overzichtspagina staat een commitgrafiek in de lege ruimte naast de centrale kolom, als er plek is. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.
14
- Op de project-overzichtspagina staat een commitgrafiek links van de centrale kolom, als er plek is. Elke commit staat op één regel; de lijnen lopen in verticale lanes met afgeronde 90-graden bochten, en de avatar is de commitknoop. De tekst begint in één kolom, rechts van de meest rechtse lane. De centrale kolom schuift iets naar rechts om de grafiek ruimte te geven; past het links niet, dan hangt hij rechts, anders blijft hij verborgen. De lijn van de in de dropdown gekozen branch gloeit. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.
15
15
- Merge requests met reviews, squash en het verwijderen van de bronbranch na een merge.
16
16
- Issues, met beschrijvingssjablonen in `.bluegit/issue_templates`. Merge requests gebruiken `.bluegit/merge_request_templates`. `Default.md` vult een lege beschrijving. Dezelfde namen onder `.gitlab/` zijn een terugval.
17
17
- Een ingebouwde CI-runner, Steve. Het bestand is `blue-ci-cd.yml`. Elke job draait in een eigen container. `image: bluegit/base` en de andere aliassen zijn image-presets die Steve lokaal bouwt.
@@ -11,7 +11,7 @@ Het logo is de blauwe ster: [`assets/logo.svg`](assets/logo.svg).11
## Wat het doet11
## Wat het doet12
12
13
- Repositories van een gebruiker of een groep, met bestanden, commits, branches, tags en releases.13
- Repositories van een gebruiker of een groep, met bestanden, commits, branches, tags en releases.14
- Op de project-overzichtspagina staat een commitgrafiek in de lege ruimte naast de centrale kolom, als er plek is. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.14
- Op de project-overzichtspagina staat een commitgrafiek links van de centrale kolom, als er plek is. Elke commit staat op één regel; de lijnen lopen in verticale lanes met afgeronde 90-graden bochten, en de avatar is de commitknoop. De tekst begint in één kolom, rechts van de meest rechtse lane. De centrale kolom schuift iets naar rechts om de grafiek ruimte te geven; past het links niet, dan hangt hij rechts, anders blijft hij verborgen. De lijn van de in de dropdown gekozen branch gloeit. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.15
- Merge requests met reviews, squash en het verwijderen van de bronbranch na een merge.15
- Merge requests met reviews, squash en het verwijderen van de bronbranch na een merge.16
- Issues, met beschrijvingssjablonen in `.bluegit/issue_templates`. Merge requests gebruiken `.bluegit/merge_request_templates`. `Default.md` vult een lege beschrijving. Dezelfde namen onder `.gitlab/` zijn een terugval.16
- Issues, met beschrijvingssjablonen in `.bluegit/issue_templates`. Merge requests gebruiken `.bluegit/merge_request_templates`. `Default.md` vult een lege beschrijving. Dezelfde namen onder `.gitlab/` zijn een terugval.17
- Een ingebouwde CI-runner, Steve. Het bestand is `blue-ci-cd.yml`. Elke job draait in een eigen container. `image: bluegit/base` en de andere aliassen zijn image-presets die Steve lokaal bouwt.17
- Een ingebouwde CI-runner, Steve. Het bestand is `blue-ci-cd.yml`. Elke job draait in een eigen container. `image: bluegit/base` en de andere aliassen zijn image-presets die Steve lokaal bouwt.@@ -95,6 +95,6 @@ Webhooks gaan niet naar een privénetwerk. De classificatie staat in `internal/s
95
95
96
96
## Commitgrafiek
97
97
98
De project-overzichtspagina toont een commitgrafiek in de lege ruimte links van de centrale kolom, als die ruimte breed genoeg is. Anders blijft hij verborgen; de bestaande kolom schuift niet. De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.
98
De project-overzichtspagina toont een commitgrafiek links van de centrale kolom, als die ruimte breed genoeg is. Elke commit staat op één regel. Lijnen lopen in verticale lanes en buigen met afgeronde 90-graden hoeken naar een andere lane. De avatar van de auteur is de commitknoop, op de lane. De committekst staat in één linkse kolom die begint net rechts van de meest rechtse lane. De centrale kolom schuift iets naar rechts zodat de grafiek meer ruimte krijgt. Past hij links niet, dan hangt hij rechts van de kolom; anders blijft hij verborgen. De lane van de in de branch-dropdown gekozen branch gloeit (client-side, zonder extra request). De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.
99
99
100
100
De gelegde grafiek (recente commits over alle branches, inclusief merges en forks) staat in een begrensde LRU-cache in het geheugen, per repository (en hoofdbranch). Een herhaalde pageview doet geen git-I/O. Bij een push wist `refsChanged` de entry en vult `refreshCache` hem op de achtergrond opnieuw. Deze cache schrijft niet naar schijf en is onafhankelijk van de optionele leescache.
@@ -95,6 +95,6 @@ Webhooks gaan niet naar een privénetwerk. De classificatie staat in `internal/s95
95
96
## Commitgrafiek96
## Commitgrafiek97
97
98
De project-overzichtspagina toont een commitgrafiek in de lege ruimte links van de centrale kolom, als die ruimte breed genoeg is. Anders blijft hij verborgen; de bestaande kolom schuift niet. De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.98
De project-overzichtspagina toont een commitgrafiek links van de centrale kolom, als die ruimte breed genoeg is. Elke commit staat op één regel. Lijnen lopen in verticale lanes en buigen met afgeronde 90-graden hoeken naar een andere lane. De avatar van de auteur is de commitknoop, op de lane. De committekst staat in één linkse kolom die begint net rechts van de meest rechtse lane. De centrale kolom schuift iets naar rechts zodat de grafiek meer ruimte krijgt. Past hij links niet, dan hangt hij rechts van de kolom; anders blijft hij verborgen. De lane van de in de branch-dropdown gekozen branch gloeit (client-side, zonder extra request). De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.99
99
100
De gelegde grafiek (recente commits over alle branches, inclusief merges en forks) staat in een begrensde LRU-cache in het geheugen, per repository (en hoofdbranch). Een herhaalde pageview doet geen git-I/O. Bij een push wist `refsChanged` de entry en vult `refreshCache` hem op de achtergrond opnieuw. Deze cache schrijft niet naar schijf en is onafhankelijk van de optionele leescache.100
De gelegde grafiek (recente commits over alle branches, inclusief merges en forks) staat in een begrensde LRU-cache in het geheugen, per repository (en hoofdbranch). Een herhaalde pageview doet geen git-I/O. Bij een push wist `refsChanged` de entry en vult `refreshCache` hem op de achtergrond opnieuw. Deze cache schrijft niet naar schijf en is onafhankelijk van de optionele leescache.@@ -17,11 +17,18 @@ const DefaultLimit = 40
17
17
const PaletteSize = 8
18
18
19
19
// RowH, LaneW en DotR zijn de tekenmaten in pixels.
20
// LaneW en RowH moeten ruim genoeg zijn voor de avatar-knoop (2*DotR).
21
// Corner is de straal van een afgeronde 90-graden bocht.
22
// TextPad is de ruimte tussen de rechterkant van de laatste lane en de tekst.
23
// MsgW is de minimale breedte van de tekstkolom in het paneel.
20
24
const (
21
RowH = 22
22
LaneW = 12
23
DotR = 4.0
24
RefW = 78
25
RowH = 28
26
LaneW = 28
27
DotR = 9.0
28
RefW = 78
29
Corner = 5.0
30
TextPad = 8
31
MsgW = 180
25
32
)
26
33
27
34
// Commit is één commit voor de grafiek, met ouders.
@@ -39,9 +46,10 @@ type Ref struct {
39
46
}
40
47
41
48
// Label is een verkorte branch- of tagnaam bij een commit.
49
// Ref is de volledige naam (voor de dropdown en de gloed).
42
50
type Label struct {
43
Name, Kind, Color, Class string
44
Default bool
51
Name, Ref, Kind, Color, Class string
52
Default bool
45
53
}
46
54
47
55
// Row is één regel in de gelegde grafiek.
@@ -50,6 +58,7 @@ type Row struct {
50
58
Lane int
51
59
Color string
52
60
Class string
61
Branch string // branch die deze commit in de grafiek "bezit"
53
62
Labels []Label
54
63
Avatar string
55
64
Initial string
@@ -59,16 +68,18 @@ type Row struct {
59
68
// Edge is een lijn van een kind naar een ouder (of het einde van het venster).
60
69
type Edge struct {
61
70
FromRow, FromLane, ToRow, ToLane int
62
Color string
71
Color, Branch string
63
72
}
64
73
65
74
// Graph is een gelegde commitgrafiek, klaar om te tekenen.
66
75
type Graph struct {
67
Rows []Row
68
Edges []Edge
69
Lanes int
70
Width int
71
Height int
76
Rows []Row
77
Edges []Edge
78
Lanes int
79
Width int // breedte van het SVG-lanedeel
80
Height int
81
TextX int // x waarop de tekstkolom begint, rechts van de laatste lane
82
PanelWidth int // refs + lanes + tekst, in pixels
72
83
}
73
84
74
85
// Color is de CSS-kleur van een branch. De hoofdbranch is altijd --blue.
@@ -128,8 +139,7 @@ func Key(repoID int64, tips map[string]string, defaultBranch string, limit int)
128
139
}
129
140
130
141
type laneState struct {
131
sha string
132
color string
142
sha, color, branch string
133
143
}
134
144
135
145
// Layout wijst lanes toe en legt lijnen voor merges en forks.
@@ -153,7 +163,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
153
163
// Lane 0 is gereserveerd voor de hoofdbranch, zodat een nieuwere
154
164
// zijtak die kleur en kolom niet inpikt.
155
165
if def := defaultTip(refs, defaultBranch); def != "" {
156
lanes = []laneState{{sha: def, color: "var(--blue)"}}
166
lanes = []laneState{{sha: def, color: "var(--blue)", branch: defaultBranch}}
157
167
}
158
168
g.Rows = make([]Row, len(commits))
159
169
occupancy := make([][]laneState, len(commits)+1)
@@ -165,7 +175,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
165
175
if mainline[c.SHA] {
166
176
col = "var(--blue)"
167
177
}
168
incoming = []int{allocLane(&lanes, c.SHA, col)}
178
incoming = []int{allocLane(&lanes, c.SHA, col, branchForCommit(c.SHA, labels, defaultBranch, mainline, ""))}
169
179
}
170
180
primary := pickPrimary(incoming, lanes, c.SHA, labels, defaultBranch)
171
181
if mainline[c.SHA] {
@@ -178,6 +188,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
178
188
}
179
189
}
180
190
row := Row{Commit: commits[i], Lane: primary, Labels: labels[c.SHA]}
191
row.Branch = branchForCommit(c.SHA, labels, defaultBranch, mainline, lanes[primary].branch)
181
192
if mainline[c.SHA] {
182
193
row.Color = "var(--blue)"
183
194
} else {
@@ -196,6 +207,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
196
207
}
197
208
row.Class = ColorClass(row.Color)
198
209
lanes[primary].color = row.Color
210
lanes[primary].branch = row.Branch
199
211
g.Rows[i] = row
200
212
201
213
for _, li := range incoming {
@@ -221,11 +233,12 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
221
233
if col == "" || col == "var(--blue)" && !mainline[p] {
222
234
col = Color(p, defaultBranch)
223
235
}
224
allocLane(&lanes, p, col)
236
br := branchForCommit(p, labels, defaultBranch, mainline, "")
237
allocLane(&lanes, p, col, br)
225
238
}
226
239
if lanes[primary].sha == "" {
227
240
if firstLane(lanes, first) < 0 && first != "" {
228
allocLane(&lanes, first, row.Color)
241
allocLane(&lanes, first, row.Color, row.Branch)
229
242
}
230
243
}
231
244
}
@@ -236,7 +249,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
236
249
if len(occupancy[0]) > 0 && len(g.Rows) > 0 {
237
250
// bovenaan: de lane van de nieuwste commit is bezet
238
251
if g.Rows[0].Lane < len(occupancy[0]) {
239
occupancy[0][g.Rows[0].Lane] = laneState{sha: g.Rows[0].SHA, color: g.Rows[0].Color}
252
occupancy[0][g.Rows[0].Lane] = laneState{sha: g.Rows[0].SHA, color: g.Rows[0].Color, branch: g.Rows[0].Branch}
240
253
}
241
254
}
242
255
g.Edges = buildEdges(g.Rows, bySHA, occupancy)
@@ -256,6 +269,8 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
256
269
}
257
270
g.Width = g.Lanes * LaneW
258
271
g.Height = len(g.Rows) * RowH
272
g.TextX = g.Lanes*LaneW + TextPad
273
g.PanelWidth = RefW + g.TextX + MsgW
259
274
return g
260
275
}
261
276
@@ -265,7 +280,7 @@ func labelsBySHA(refs []Ref, defaultBranch string) map[string][]Label {
265
280
if r.SHA == "" || r.Name == "" {
266
281
continue
267
282
}
268
lb := Label{Name: shortName(r.Name), Kind: r.Kind, Color: Color(r.Name, defaultBranch), Default: r.Kind == "branch" && r.Name == defaultBranch}
283
lb := Label{Name: shortName(r.Name), Ref: r.Name, Kind: r.Kind, Color: Color(r.Name, defaultBranch), Default: r.Kind == "branch" && r.Name == defaultBranch}
269
284
if r.Kind == "tag" {
270
285
lb.Color = "var(--muted)"
271
286
lb.Class = "is-tag"
@@ -353,17 +368,40 @@ func pickPrimary(incoming []int, lanes []laneState, sha string, labels map[strin
353
368
return incoming[0]
354
369
}
355
370
356
func allocLane(lanes *[]laneState, sha, color string) int {
371
func allocLane(lanes *[]laneState, sha, color, branch string) int {
357
372
for i, l := range *lanes {
358
373
if l.sha == "" {
359
(*lanes)[i] = laneState{sha: sha, color: color}
374
(*lanes)[i] = laneState{sha: sha, color: color, branch: branch}
360
375
return i
361
376
}
362
377
}
363
*lanes = append(*lanes, laneState{sha: sha, color: color})
378
*lanes = append(*lanes, laneState{sha: sha, color: color, branch: branch})
364
379
return len(*lanes) - 1
365
380
}
366
381
382
func branchForCommit(sha string, labels map[string][]Label, defaultBranch string, mainline map[string]bool, fallback string) string {
383
for _, lb := range labels[sha] {
384
if lb.Default && lb.Ref != "" {
385
return lb.Ref
386
}
387
if lb.Default && defaultBranch != "" {
388
return defaultBranch
389
}
390
}
391
for _, lb := range labels[sha] {
392
if lb.Kind == "branch" && lb.Ref != "" {
393
return lb.Ref
394
}
395
if lb.Kind == "branch" && lb.Name != "" {
396
return lb.Name
397
}
398
}
399
if mainline[sha] && defaultBranch != "" {
400
return defaultBranch
401
}
402
return fallback
403
}
404
367
405
func copyLanes(lanes []laneState) []laneState {
368
406
out := make([]laneState, len(lanes))
369
407
copy(out, lanes)
@@ -412,9 +450,16 @@ func buildEdges(rows []Row, bySHA map[string]int, occ [][]laneState) []Edge {
412
450
}
413
451
toRow = len(rows) - 1
414
452
}
415
col := r.Color
416
if pi == 0 && r.Color != "" {
417
col = r.Color
453
col, branch := r.Color, r.Branch
454
if pi > 0 {
455
if j, ok := bySHA[p]; ok {
456
if rows[j].Color != "" {
457
col = rows[j].Color
458
}
459
if rows[j].Branch != "" {
460
branch = rows[j].Branch
461
}
462
}
418
463
}
419
464
// Tussenliggende verticale stukken volgen de gereserveerde lane.
420
465
fromLane := r.Lane
@@ -422,14 +467,14 @@ func buildEdges(rows []Row, bySHA map[string]int, occ [][]laneState) []Edge {
422
467
if idx := firstLane(occ[i+1], p); idx >= 0 {
423
468
fromLane = idx
424
469
// boog vanaf de merge-commit naar de ouder-lane op de volgende rij
425
add(Edge{FromRow: i, FromLane: r.Lane, ToRow: i + 1, ToLane: fromLane, Color: col})
470
add(Edge{FromRow: i, FromLane: r.Lane, ToRow: i + 1, ToLane: fromLane, Color: col, Branch: branch})
426
471
if toRow > i+1 {
427
add(Edge{FromRow: i + 1, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col})
472
add(Edge{FromRow: i + 1, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col, Branch: branch})
428
473
}
429
474
continue
430
475
}
431
476
}
432
add(Edge{FromRow: i, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col})
477
add(Edge{FromRow: i, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col, Branch: branch})
433
478
}
434
479
}
435
480
return edges
@@ -17,11 +17,18 @@ const DefaultLimit = 4017
const PaletteSize = 817
const PaletteSize = 818
18
19
// RowH, LaneW en DotR zijn de tekenmaten in pixels.19
// RowH, LaneW en DotR zijn de tekenmaten in pixels.20
// LaneW en RowH moeten ruim genoeg zijn voor de avatar-knoop (2*DotR).21
// Corner is de straal van een afgeronde 90-graden bocht.22
// TextPad is de ruimte tussen de rechterkant van de laatste lane en de tekst.23
// MsgW is de minimale breedte van de tekstkolom in het paneel.20
const (24
const (21
RowH = 2225
RowH = 2822
LaneW = 1226
LaneW = 2823
DotR = 4.027
DotR = 9.024
RefW = 7828
RefW = 7829
Corner = 5.030
TextPad = 831
MsgW = 18025
)32
)26
33
27
// Commit is één commit voor de grafiek, met ouders.34
// Commit is één commit voor de grafiek, met ouders.@@ -39,9 +46,10 @@ type Ref struct {39
}46
}40
47
41
// Label is een verkorte branch- of tagnaam bij een commit.48
// Label is een verkorte branch- of tagnaam bij een commit.49
// Ref is de volledige naam (voor de dropdown en de gloed).42
type Label struct {50
type Label struct {43
Name, Kind, Color, Class string51
Name, Ref, Kind, Color, Class string44
Default bool52
Default bool45
}53
}46
54
47
// Row is één regel in de gelegde grafiek.55
// Row is één regel in de gelegde grafiek.@@ -50,6 +58,7 @@ type Row struct {50
Lane int58
Lane int51
Color string59
Color string52
Class string60
Class string61
Branch string // branch die deze commit in de grafiek "bezit"53
Labels []Label62
Labels []Label54
Avatar string63
Avatar string55
Initial string64
Initial string@@ -59,16 +68,18 @@ type Row struct {59
// Edge is een lijn van een kind naar een ouder (of het einde van het venster).68
// Edge is een lijn van een kind naar een ouder (of het einde van het venster).60
type Edge struct {69
type Edge struct {61
FromRow, FromLane, ToRow, ToLane int70
FromRow, FromLane, ToRow, ToLane int62
Color string71
Color, Branch string63
}72
}64
73
65
// Graph is een gelegde commitgrafiek, klaar om te tekenen.74
// Graph is een gelegde commitgrafiek, klaar om te tekenen.66
type Graph struct {75
type Graph struct {67
Rows []Row76
Rows []Row68
Edges []Edge77
Edges []Edge69
Lanes int78
Lanes int70
Width int79
Width int // breedte van het SVG-lanedeel71
Height int80
Height int81
TextX int // x waarop de tekstkolom begint, rechts van de laatste lane82
PanelWidth int // refs + lanes + tekst, in pixels72
}83
}73
84
74
// Color is de CSS-kleur van een branch. De hoofdbranch is altijd --blue.85
// Color is de CSS-kleur van een branch. De hoofdbranch is altijd --blue.@@ -128,8 +139,7 @@ func Key(repoID int64, tips map[string]string, defaultBranch string, limit int)128
}139
}129
140
130
type laneState struct {141
type laneState struct {131
sha string142
sha, color, branch string132
color string133
}143
}134
144
135
// Layout wijst lanes toe en legt lijnen voor merges en forks.145
// Layout wijst lanes toe en legt lijnen voor merges en forks.@@ -153,7 +163,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {153
// Lane 0 is gereserveerd voor de hoofdbranch, zodat een nieuwere163
// Lane 0 is gereserveerd voor de hoofdbranch, zodat een nieuwere154
// zijtak die kleur en kolom niet inpikt.164
// zijtak die kleur en kolom niet inpikt.155
if def := defaultTip(refs, defaultBranch); def != "" {165
if def := defaultTip(refs, defaultBranch); def != "" {156
lanes = []laneState{{sha: def, color: "var(--blue)"}}166
lanes = []laneState{{sha: def, color: "var(--blue)", branch: defaultBranch}}157
}167
}158
g.Rows = make([]Row, len(commits))168
g.Rows = make([]Row, len(commits))159
occupancy := make([][]laneState, len(commits)+1)169
occupancy := make([][]laneState, len(commits)+1)@@ -165,7 +175,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {165
if mainline[c.SHA] {175
if mainline[c.SHA] {166
col = "var(--blue)"176
col = "var(--blue)"167
}177
}168
incoming = []int{allocLane(&lanes, c.SHA, col)}178
incoming = []int{allocLane(&lanes, c.SHA, col, branchForCommit(c.SHA, labels, defaultBranch, mainline, ""))}169
}179
}170
primary := pickPrimary(incoming, lanes, c.SHA, labels, defaultBranch)180
primary := pickPrimary(incoming, lanes, c.SHA, labels, defaultBranch)171
if mainline[c.SHA] {181
if mainline[c.SHA] {@@ -178,6 +188,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {178
}188
}179
}189
}180
row := Row{Commit: commits[i], Lane: primary, Labels: labels[c.SHA]}190
row := Row{Commit: commits[i], Lane: primary, Labels: labels[c.SHA]}191
row.Branch = branchForCommit(c.SHA, labels, defaultBranch, mainline, lanes[primary].branch)181
if mainline[c.SHA] {192
if mainline[c.SHA] {182
row.Color = "var(--blue)"193
row.Color = "var(--blue)"183
} else {194
} else {@@ -196,6 +207,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {196
}207
}197
row.Class = ColorClass(row.Color)208
row.Class = ColorClass(row.Color)198
lanes[primary].color = row.Color209
lanes[primary].color = row.Color210
lanes[primary].branch = row.Branch199
g.Rows[i] = row211
g.Rows[i] = row200
212
201
for _, li := range incoming {213
for _, li := range incoming {@@ -221,11 +233,12 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {221
if col == "" || col == "var(--blue)" && !mainline[p] {233
if col == "" || col == "var(--blue)" && !mainline[p] {222
col = Color(p, defaultBranch)234
col = Color(p, defaultBranch)223
}235
}224
allocLane(&lanes, p, col)236
br := branchForCommit(p, labels, defaultBranch, mainline, "")237
allocLane(&lanes, p, col, br)225
}238
}226
if lanes[primary].sha == "" {239
if lanes[primary].sha == "" {227
if firstLane(lanes, first) < 0 && first != "" {240
if firstLane(lanes, first) < 0 && first != "" {228
allocLane(&lanes, first, row.Color)241
allocLane(&lanes, first, row.Color, row.Branch)229
}242
}230
}243
}231
}244
}@@ -236,7 +249,7 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {236
if len(occupancy[0]) > 0 && len(g.Rows) > 0 {249
if len(occupancy[0]) > 0 && len(g.Rows) > 0 {237
// bovenaan: de lane van de nieuwste commit is bezet250
// bovenaan: de lane van de nieuwste commit is bezet238
if g.Rows[0].Lane < len(occupancy[0]) {251
if g.Rows[0].Lane < len(occupancy[0]) {239
occupancy[0][g.Rows[0].Lane] = laneState{sha: g.Rows[0].SHA, color: g.Rows[0].Color}252
occupancy[0][g.Rows[0].Lane] = laneState{sha: g.Rows[0].SHA, color: g.Rows[0].Color, branch: g.Rows[0].Branch}240
}253
}241
}254
}242
g.Edges = buildEdges(g.Rows, bySHA, occupancy)255
g.Edges = buildEdges(g.Rows, bySHA, occupancy)@@ -256,6 +269,8 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {256
}269
}257
g.Width = g.Lanes * LaneW270
g.Width = g.Lanes * LaneW258
g.Height = len(g.Rows) * RowH271
g.Height = len(g.Rows) * RowH272
g.TextX = g.Lanes*LaneW + TextPad273
g.PanelWidth = RefW + g.TextX + MsgW259
return g274
return g260
}275
}261
276
@@ -265,7 +280,7 @@ func labelsBySHA(refs []Ref, defaultBranch string) map[string][]Label {265
if r.SHA == "" || r.Name == "" {280
if r.SHA == "" || r.Name == "" {266
continue281
continue267
}282
}268
lb := Label{Name: shortName(r.Name), Kind: r.Kind, Color: Color(r.Name, defaultBranch), Default: r.Kind == "branch" && r.Name == defaultBranch}283
lb := Label{Name: shortName(r.Name), Ref: r.Name, Kind: r.Kind, Color: Color(r.Name, defaultBranch), Default: r.Kind == "branch" && r.Name == defaultBranch}269
if r.Kind == "tag" {284
if r.Kind == "tag" {270
lb.Color = "var(--muted)"285
lb.Color = "var(--muted)"271
lb.Class = "is-tag"286
lb.Class = "is-tag"@@ -353,17 +368,40 @@ func pickPrimary(incoming []int, lanes []laneState, sha string, labels map[strin353
return incoming[0]368
return incoming[0]354
}369
}355
370
356
func allocLane(lanes *[]laneState, sha, color string) int {371
func allocLane(lanes *[]laneState, sha, color, branch string) int {357
for i, l := range *lanes {372
for i, l := range *lanes {358
if l.sha == "" {373
if l.sha == "" {359
(*lanes)[i] = laneState{sha: sha, color: color}374
(*lanes)[i] = laneState{sha: sha, color: color, branch: branch}360
return i375
return i361
}376
}362
}377
}363
*lanes = append(*lanes, laneState{sha: sha, color: color})378
*lanes = append(*lanes, laneState{sha: sha, color: color, branch: branch})364
return len(*lanes) - 1379
return len(*lanes) - 1365
}380
}366
381
382
func branchForCommit(sha string, labels map[string][]Label, defaultBranch string, mainline map[string]bool, fallback string) string {383
for _, lb := range labels[sha] {384
if lb.Default && lb.Ref != "" {385
return lb.Ref386
}387
if lb.Default && defaultBranch != "" {388
return defaultBranch389
}390
}391
for _, lb := range labels[sha] {392
if lb.Kind == "branch" && lb.Ref != "" {393
return lb.Ref394
}395
if lb.Kind == "branch" && lb.Name != "" {396
return lb.Name397
}398
}399
if mainline[sha] && defaultBranch != "" {400
return defaultBranch401
}402
return fallback403
}404
367
func copyLanes(lanes []laneState) []laneState {405
func copyLanes(lanes []laneState) []laneState {368
out := make([]laneState, len(lanes))406
out := make([]laneState, len(lanes))369
copy(out, lanes)407
copy(out, lanes)@@ -412,9 +450,16 @@ func buildEdges(rows []Row, bySHA map[string]int, occ [][]laneState) []Edge {412
}450
}413
toRow = len(rows) - 1451
toRow = len(rows) - 1414
}452
}415
col := r.Color453
col, branch := r.Color, r.Branch416
if pi == 0 && r.Color != "" {454
if pi > 0 {417
col = r.Color455
if j, ok := bySHA[p]; ok {456
if rows[j].Color != "" {457
col = rows[j].Color458
}459
if rows[j].Branch != "" {460
branch = rows[j].Branch461
}462
}418
}463
}419
// Tussenliggende verticale stukken volgen de gereserveerde lane.464
// Tussenliggende verticale stukken volgen de gereserveerde lane.420
fromLane := r.Lane465
fromLane := r.Lane@@ -422,14 +467,14 @@ func buildEdges(rows []Row, bySHA map[string]int, occ [][]laneState) []Edge {422
if idx := firstLane(occ[i+1], p); idx >= 0 {467
if idx := firstLane(occ[i+1], p); idx >= 0 {423
fromLane = idx468
fromLane = idx424
// boog vanaf de merge-commit naar de ouder-lane op de volgende rij469
// boog vanaf de merge-commit naar de ouder-lane op de volgende rij425
add(Edge{FromRow: i, FromLane: r.Lane, ToRow: i + 1, ToLane: fromLane, Color: col})470
add(Edge{FromRow: i, FromLane: r.Lane, ToRow: i + 1, ToLane: fromLane, Color: col, Branch: branch})426
if toRow > i+1 {471
if toRow > i+1 {427
add(Edge{FromRow: i + 1, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col})472
add(Edge{FromRow: i + 1, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col, Branch: branch})428
}473
}429
continue474
continue430
}475
}431
}476
}432
add(Edge{FromRow: i, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col})477
add(Edge{FromRow: i, FromLane: fromLane, ToRow: toRow, ToLane: toLane, Color: col, Branch: branch})433
}478
}434
}479
}435
return edges480
return edges@@ -242,3 +242,76 @@ func TestMainlineStaysBlueOnLaneZero(t *testing.T) {
242
242
}
243
243
}
244
244
}
245
246
func TestOneCommitPerRow(t *testing.T) {
247
refs := []Ref{
248
{Name: "master", SHA: "m", Kind: "branch"},
249
{Name: "feature", SHA: "e", Kind: "branch"},
250
{Name: "docs", SHA: "d", Kind: "branch"},
251
}
252
g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")
253
if len(g.Rows) != 6 {
254
t.Fatalf("rijen=%d, wil één per commit", len(g.Rows))
255
}
256
seen := map[string]int{}
257
for i, r := range g.Rows {
258
if r.SHA == "" {
259
t.Fatalf("lege commit op rij %d", i)
260
}
261
if j, ok := seen[r.SHA]; ok {
262
t.Fatalf("commit %s staat op rij %d en %d", r.SHA, j, i)
263
}
264
seen[r.SHA] = i
265
}
266
}
267
268
func TestTextXIsRightOfLanes(t *testing.T) {
269
refs := []Ref{
270
{Name: "master", SHA: "m", Kind: "branch"},
271
{Name: "feature", SHA: "e", Kind: "branch"},
272
{Name: "docs", SHA: "d", Kind: "branch"},
273
}
274
g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")
275
if g.Lanes < 2 {
276
t.Fatalf("verwacht meerdere lanes, kreeg %d", g.Lanes)
277
}
278
maxLaneRight := 0.0
279
for i := 0; i < g.Lanes; i++ {
280
right := laneX(i) + float64(LaneW)/2
281
if right > maxLaneRight {
282
maxLaneRight = right
283
}
284
}
285
if float64(g.TextX) < maxLaneRight {
286
t.Fatalf("TextX=%d ligt niet rechts van de laatste lane (%.1f), lanes=%d", g.TextX, maxLaneRight, g.Lanes)
287
}
288
if g.PanelWidth < RefW+g.TextX {
289
t.Fatalf("PanelWidth=%d is te smal voor refs+tekst (TextX=%d)", g.PanelWidth, g.TextX)
290
}
291
}
292
293
func TestLaneAssignmentStable(t *testing.T) {
294
refs := []Ref{
295
{Name: "master", SHA: "m", Kind: "branch"},
296
{Name: "feature", SHA: "f", Kind: "branch"},
297
}
298
g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
299
laneOf := map[string]int{}
300
for _, r := range g.Rows {
301
laneOf[r.SHA] = r.Lane
302
}
303
if laneOf["m"] != 0 || laneOf["c"] != 0 || laneOf["b"] != 0 {
304
t.Fatalf("master moet lane 0 blijven: %v", laneOf)
305
}
306
if laneOf["f"] == 0 {
307
t.Fatalf("feature mag lane 0 niet gebruiken: %v", laneOf)
308
}
309
if g.Rows[0].Branch != "master" {
310
t.Fatalf("merge-commit branch=%q", g.Rows[0].Branch)
311
}
312
for _, r := range g.Rows {
313
if r.SHA == "f" && r.Branch != "feature" {
314
t.Fatalf("feature-commit branch=%q", r.Branch)
315
}
316
}
317
}
@@ -242,3 +242,76 @@ func TestMainlineStaysBlueOnLaneZero(t *testing.T) {242
}242
}243
}243
}244
}244
}245
246
func TestOneCommitPerRow(t *testing.T) {247
refs := []Ref{248
{Name: "master", SHA: "m", Kind: "branch"},249
{Name: "feature", SHA: "e", Kind: "branch"},250
{Name: "docs", SHA: "d", Kind: "branch"},251
}252
g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")253
if len(g.Rows) != 6 {254
t.Fatalf("rijen=%d, wil één per commit", len(g.Rows))255
}256
seen := map[string]int{}257
for i, r := range g.Rows {258
if r.SHA == "" {259
t.Fatalf("lege commit op rij %d", i)260
}261
if j, ok := seen[r.SHA]; ok {262
t.Fatalf("commit %s staat op rij %d en %d", r.SHA, j, i)263
}264
seen[r.SHA] = i265
}266
}267
268
func TestTextXIsRightOfLanes(t *testing.T) {269
refs := []Ref{270
{Name: "master", SHA: "m", Kind: "branch"},271
{Name: "feature", SHA: "e", Kind: "branch"},272
{Name: "docs", SHA: "d", Kind: "branch"},273
}274
g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")275
if g.Lanes < 2 {276
t.Fatalf("verwacht meerdere lanes, kreeg %d", g.Lanes)277
}278
maxLaneRight := 0.0279
for i := 0; i < g.Lanes; i++ {280
right := laneX(i) + float64(LaneW)/2281
if right > maxLaneRight {282
maxLaneRight = right283
}284
}285
if float64(g.TextX) < maxLaneRight {286
t.Fatalf("TextX=%d ligt niet rechts van de laatste lane (%.1f), lanes=%d", g.TextX, maxLaneRight, g.Lanes)287
}288
if g.PanelWidth < RefW+g.TextX {289
t.Fatalf("PanelWidth=%d is te smal voor refs+tekst (TextX=%d)", g.PanelWidth, g.TextX)290
}291
}292
293
func TestLaneAssignmentStable(t *testing.T) {294
refs := []Ref{295
{Name: "master", SHA: "m", Kind: "branch"},296
{Name: "feature", SHA: "f", Kind: "branch"},297
}298
g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")299
laneOf := map[string]int{}300
for _, r := range g.Rows {301
laneOf[r.SHA] = r.Lane302
}303
if laneOf["m"] != 0 || laneOf["c"] != 0 || laneOf["b"] != 0 {304
t.Fatalf("master moet lane 0 blijven: %v", laneOf)305
}306
if laneOf["f"] == 0 {307
t.Fatalf("feature mag lane 0 niet gebruiken: %v", laneOf)308
}309
if g.Rows[0].Branch != "master" {310
t.Fatalf("merge-commit branch=%q", g.Rows[0].Branch)311
}312
for _, r := range g.Rows {313
if r.SHA == "f" && r.Branch != "feature" {314
t.Fatalf("feature-commit branch=%q", r.Branch)315
}316
}317
}@@ -3,10 +3,13 @@ package gitgraph
3
3
import (
4
4
"fmt"
5
5
"html"
6
"math"
6
7
"strings"
7
8
)
8
9
9
// SVG tekent de lanelijnen. Alleen getallen en paletkleuren, veilig als HTML.
10
// SVG tekent de lanelijnen met afgeronde 90-graden bochten.
11
// Alleen getallen en paletkleuren, veilig als HTML. De knopen zelf
12
// zijn de avatars in de HTML, niet de SVG.
10
13
func (g *Graph) SVG() string {
11
14
if g == nil || len(g.Rows) == 0 || g.Lanes < 1 {
12
15
return ""
@@ -16,30 +19,66 @@ func (g *Graph) SVG() string {
16
19
b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" viewBox="0 0 %d %d" width="%d" height="%d" aria-hidden="true">`, w, h, w, h))
17
20
for _, e := range g.Edges {
18
21
col := safeColor(e.Color)
22
cls := ColorClass(e.Color)
19
23
x1, y1 := laneX(e.FromLane), rowY(e.FromRow)
20
24
x2, y2 := laneX(e.ToLane), rowY(e.ToRow)
21
if e.FromLane == e.ToLane {
22
fmt.Fprintf(&b, `<path d="M %.1f %.1f V %.1f" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round"/>`, x1, y1, y2, col)
23
continue
25
d := orthogonalPath(x1, y1, x2, y2, Corner)
26
fmt.Fprintf(&b, `<path d="%s" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`, d, col)
27
if cls != "" {
28
fmt.Fprintf(&b, ` class="%s"`, cls)
24
29
}
25
// Boog tussen lanes: horizontaal op halve rij, dan verticaal.
26
midY := y1 + float64(RowH)/2
27
if e.ToRow == e.FromRow+1 {
28
// korte merge/fork naar de volgende rij
29
fmt.Fprintf(&b, `<path d="M %.1f %.1f C %.1f %.1f, %.1f %.1f, %.1f %.1f" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round"/>`,
30
x1, y1, x1, midY, x2, midY, x2, y2, col)
31
continue
30
if e.Branch != "" {
31
fmt.Fprintf(&b, ` data-branch="%s"`, html.EscapeString(e.Branch))
32
32
}
33
fmt.Fprintf(&b, `<path d="M %.1f %.1f C %.1f %.1f, %.1f %.1f, %.1f %.1f V %.1f" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round"/>`,
34
x1, y1, x1, midY, x2, midY, x2, y1+float64(RowH), y2, col)
35
}
36
for i, r := range g.Rows {
37
fmt.Fprintf(&b, `<circle cx="%.1f" cy="%.1f" r="%.1f" fill="%s"/>`, laneX(r.Lane), rowY(i), DotR, safeColor(r.Color))
33
b.WriteString(`/>`)
38
34
}
39
35
b.WriteString(`</svg>`)
40
36
return b.String()
41
37
}
42
38
39
// orthogonalPath gaat verticaal, dan horizontaal, dan weer verticaal,
40
// met afgeronde 90-graden bochten. Bij dezelfde lane is het een rechte lijn.
41
func orthogonalPath(x1, y1, x2, y2, r float64) string {
42
if almostEq(x1, x2) {
43
return fmt.Sprintf("M %.1f %.1f V %.1f", x1, y1, y2)
44
}
45
if almostEq(y1, y2) {
46
return fmt.Sprintf("M %.1f %.1f H %.1f", x1, y1, x2)
47
}
48
// Vroege overstap: bocht halverwege de volgende rij, daarna verticaal in de doellane.
49
turnY := y1 + float64(RowH)/2
50
if (y2-y1) > 0 && turnY > y2-1 {
51
turnY = (y1 + y2) / 2
52
}
53
dx := math.Abs(x2 - x1)
54
up := math.Abs(turnY - y1)
55
down := math.Abs(y2 - turnY)
56
maxR := math.Min(r, dx/2)
57
maxR = math.Min(maxR, up)
58
maxR = math.Min(maxR, down)
59
if maxR < 1 {
60
// te krap voor een boog: alsnog een knik, zonder afronding
61
return fmt.Sprintf("M %.1f %.1f V %.1f H %.1f V %.1f", x1, y1, turnY, x2, y2)
62
}
63
dir := 1.0
64
if x2 < x1 {
65
dir = -1
66
}
67
return fmt.Sprintf(
68
"M %.1f %.1f V %.1f Q %.1f %.1f, %.1f %.1f H %.1f Q %.1f %.1f, %.1f %.1f V %.1f",
69
x1, y1,
70
turnY-maxR,
71
x1, turnY, x1+dir*maxR, turnY,
72
x2-dir*maxR,
73
x2, turnY, x2, turnY+maxR,
74
y2,
75
)
76
}
77
78
func almostEq(a, b float64) bool {
79
return math.Abs(a-b) < 0.05
80
}
81
43
82
func laneX(lane int) float64 {
44
83
return float64(lane)*float64(LaneW) + float64(LaneW)/2
45
84
}
@@ -3,10 +3,13 @@ package gitgraph3
import (3
import (4
"fmt"4
"fmt"5
"html"5
"html"6
"math"6
"strings"7
"strings"7
)8
)8
9
9
// SVG tekent de lanelijnen. Alleen getallen en paletkleuren, veilig als HTML.10
// SVG tekent de lanelijnen met afgeronde 90-graden bochten.11
// Alleen getallen en paletkleuren, veilig als HTML. De knopen zelf12
// zijn de avatars in de HTML, niet de SVG.10
func (g *Graph) SVG() string {13
func (g *Graph) SVG() string {11
if g == nil || len(g.Rows) == 0 || g.Lanes < 1 {14
if g == nil || len(g.Rows) == 0 || g.Lanes < 1 {12
return ""15
return ""@@ -16,30 +19,66 @@ func (g *Graph) SVG() string {16
b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" viewBox="0 0 %d %d" width="%d" height="%d" aria-hidden="true">`, w, h, w, h))19
b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" viewBox="0 0 %d %d" width="%d" height="%d" aria-hidden="true">`, w, h, w, h))17
for _, e := range g.Edges {20
for _, e := range g.Edges {18
col := safeColor(e.Color)21
col := safeColor(e.Color)22
cls := ColorClass(e.Color)19
x1, y1 := laneX(e.FromLane), rowY(e.FromRow)23
x1, y1 := laneX(e.FromLane), rowY(e.FromRow)20
x2, y2 := laneX(e.ToLane), rowY(e.ToRow)24
x2, y2 := laneX(e.ToLane), rowY(e.ToRow)21
if e.FromLane == e.ToLane {25
d := orthogonalPath(x1, y1, x2, y2, Corner)22
fmt.Fprintf(&b, `<path d="M %.1f %.1f V %.1f" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round"/>`, x1, y1, y2, col)26
fmt.Fprintf(&b, `<path d="%s" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`, d, col)23
continue27
if cls != "" {28
fmt.Fprintf(&b, ` class="%s"`, cls)24
}29
}25
// Boog tussen lanes: horizontaal op halve rij, dan verticaal.30
if e.Branch != "" {26
midY := y1 + float64(RowH)/231
fmt.Fprintf(&b, ` data-branch="%s"`, html.EscapeString(e.Branch))27
if e.ToRow == e.FromRow+1 {28
// korte merge/fork naar de volgende rij29
fmt.Fprintf(&b, `<path d="M %.1f %.1f C %.1f %.1f, %.1f %.1f, %.1f %.1f" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round"/>`,30
x1, y1, x1, midY, x2, midY, x2, y2, col)31
continue32
}32
}33
fmt.Fprintf(&b, `<path d="M %.1f %.1f C %.1f %.1f, %.1f %.1f, %.1f %.1f V %.1f" fill="none" stroke="%s" stroke-width="2" stroke-linecap="round"/>`,33
b.WriteString(`/>`)34
x1, y1, x1, midY, x2, midY, x2, y1+float64(RowH), y2, col)35
}36
for i, r := range g.Rows {37
fmt.Fprintf(&b, `<circle cx="%.1f" cy="%.1f" r="%.1f" fill="%s"/>`, laneX(r.Lane), rowY(i), DotR, safeColor(r.Color))38
}34
}39
b.WriteString(`</svg>`)35
b.WriteString(`</svg>`)40
return b.String()36
return b.String()41
}37
}42
38
39
// orthogonalPath gaat verticaal, dan horizontaal, dan weer verticaal,40
// met afgeronde 90-graden bochten. Bij dezelfde lane is het een rechte lijn.41
func orthogonalPath(x1, y1, x2, y2, r float64) string {42
if almostEq(x1, x2) {43
return fmt.Sprintf("M %.1f %.1f V %.1f", x1, y1, y2)44
}45
if almostEq(y1, y2) {46
return fmt.Sprintf("M %.1f %.1f H %.1f", x1, y1, x2)47
}48
// Vroege overstap: bocht halverwege de volgende rij, daarna verticaal in de doellane.49
turnY := y1 + float64(RowH)/250
if (y2-y1) > 0 && turnY > y2-1 {51
turnY = (y1 + y2) / 252
}53
dx := math.Abs(x2 - x1)54
up := math.Abs(turnY - y1)55
down := math.Abs(y2 - turnY)56
maxR := math.Min(r, dx/2)57
maxR = math.Min(maxR, up)58
maxR = math.Min(maxR, down)59
if maxR < 1 {60
// te krap voor een boog: alsnog een knik, zonder afronding61
return fmt.Sprintf("M %.1f %.1f V %.1f H %.1f V %.1f", x1, y1, turnY, x2, y2)62
}63
dir := 1.064
if x2 < x1 {65
dir = -166
}67
return fmt.Sprintf(68
"M %.1f %.1f V %.1f Q %.1f %.1f, %.1f %.1f H %.1f Q %.1f %.1f, %.1f %.1f V %.1f",69
x1, y1,70
turnY-maxR,71
x1, turnY, x1+dir*maxR, turnY,72
x2-dir*maxR,73
x2, turnY, x2, turnY+maxR,74
y2,75
)76
}77
78
func almostEq(a, b float64) bool {79
return math.Abs(a-b) < 0.0580
}81
43
func laneX(lane int) float64 {82
func laneX(lane int) float64 {44
return float64(lane)*float64(LaneW) + float64(LaneW)/283
return float64(lane)*float64(LaneW) + float64(LaneW)/245
}84
}@@ -0,0 +1,68 @@
1
package gitgraph
2
3
import (
4
"strings"
5
"testing"
6
)
7
8
func TestSVGUsesRoundedOrthogonalBends(t *testing.T) {
9
refs := []Ref{
10
{Name: "master", SHA: "m", Kind: "branch"},
11
{Name: "feature", SHA: "f", Kind: "branch"},
12
}
13
g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
14
svg := g.SVG()
15
if svg == "" {
16
t.Fatal("lege svg")
17
}
18
if strings.Contains(svg, " C ") || strings.Contains(svg, `"C `) || strings.Contains(svg, " C") {
19
// cubische beziers geven diagonale lijnen; we willen knikken
20
if strings.Contains(svg, " C ") {
21
t.Fatalf("svg gebruikt nog een diagonale bezier: %s", svg)
22
}
23
}
24
if !strings.Contains(svg, " Q ") {
25
t.Fatalf("verwacht afgeronde bochten (Q) in %s", svg)
26
}
27
if !strings.Contains(svg, " V ") && !strings.Contains(svg, "V ") {
28
t.Fatalf("verwacht verticale stukken in %s", svg)
29
}
30
if !strings.Contains(svg, " H ") {
31
t.Fatalf("verwacht horizontale stukken in %s", svg)
32
}
33
if strings.Contains(svg, "<circle") {
34
t.Fatalf("knopen horen avatars te zijn, geen svg-cirkels: %s", svg)
35
}
36
if !strings.Contains(svg, `data-branch="master"`) {
37
t.Fatalf("gloed-attribuut voor master ontbreekt: %s", svg)
38
}
39
if !strings.Contains(svg, `data-branch="feature"`) {
40
t.Fatalf("gloed-attribuut voor feature ontbreekt: %s", svg)
41
}
42
if !strings.Contains(svg, `stroke="var(--blue)"`) {
43
t.Fatalf("blauwe hoofdlijn ontbreekt: %s", svg)
44
}
45
}
46
47
func TestOrthogonalPathShape(t *testing.T) {
48
// zelfde lane: alleen verticaal
49
d := orthogonalPath(12, 14, 12, 70, 7)
50
if d != "M 12.0 14.0 V 70.0" {
51
t.Fatalf("verticaal: %s", d)
52
}
53
// andere lane: V, Q, H, Q, V
54
d = orthogonalPath(12, 14, 36, 70, 7)
55
if !strings.Contains(d, " Q ") || !strings.Contains(d, " H ") || !strings.Contains(d, " V ") {
56
t.Fatalf("bocht mist commando's: %s", d)
57
}
58
if strings.Contains(d, " C ") {
59
t.Fatalf("geen bezier: %s", d)
60
}
61
// de bocht gaat eerst naar beneden, dan opzij, dan weer naar beneden
62
if !strings.HasPrefix(d, "M 12.0 14.0 V ") {
63
t.Fatalf("start niet verticaal: %s", d)
64
}
65
if !strings.HasSuffix(d, " V 70.0") {
66
t.Fatalf("eindigt niet verticaal op het doel: %s", d)
67
}
68
}
@@ -0,0 +1,68 @@1
package gitgraph2
3
import (4
"strings"5
"testing"6
)7
8
func TestSVGUsesRoundedOrthogonalBends(t *testing.T) {9
refs := []Ref{10
{Name: "master", SHA: "m", Kind: "branch"},11
{Name: "feature", SHA: "f", Kind: "branch"},12
}13
g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")14
svg := g.SVG()15
if svg == "" {16
t.Fatal("lege svg")17
}18
if strings.Contains(svg, " C ") || strings.Contains(svg, `"C `) || strings.Contains(svg, " C") {19
// cubische beziers geven diagonale lijnen; we willen knikken20
if strings.Contains(svg, " C ") {21
t.Fatalf("svg gebruikt nog een diagonale bezier: %s", svg)22
}23
}24
if !strings.Contains(svg, " Q ") {25
t.Fatalf("verwacht afgeronde bochten (Q) in %s", svg)26
}27
if !strings.Contains(svg, " V ") && !strings.Contains(svg, "V ") {28
t.Fatalf("verwacht verticale stukken in %s", svg)29
}30
if !strings.Contains(svg, " H ") {31
t.Fatalf("verwacht horizontale stukken in %s", svg)32
}33
if strings.Contains(svg, "<circle") {34
t.Fatalf("knopen horen avatars te zijn, geen svg-cirkels: %s", svg)35
}36
if !strings.Contains(svg, `data-branch="master"`) {37
t.Fatalf("gloed-attribuut voor master ontbreekt: %s", svg)38
}39
if !strings.Contains(svg, `data-branch="feature"`) {40
t.Fatalf("gloed-attribuut voor feature ontbreekt: %s", svg)41
}42
if !strings.Contains(svg, `stroke="var(--blue)"`) {43
t.Fatalf("blauwe hoofdlijn ontbreekt: %s", svg)44
}45
}46
47
func TestOrthogonalPathShape(t *testing.T) {48
// zelfde lane: alleen verticaal49
d := orthogonalPath(12, 14, 12, 70, 7)50
if d != "M 12.0 14.0 V 70.0" {51
t.Fatalf("verticaal: %s", d)52
}53
// andere lane: V, Q, H, Q, V54
d = orthogonalPath(12, 14, 36, 70, 7)55
if !strings.Contains(d, " Q ") || !strings.Contains(d, " H ") || !strings.Contains(d, " V ") {56
t.Fatalf("bocht mist commando's: %s", d)57
}58
if strings.Contains(d, " C ") {59
t.Fatalf("geen bezier: %s", d)60
}61
// de bocht gaat eerst naar beneden, dan opzij, dan weer naar beneden62
if !strings.HasPrefix(d, "M 12.0 14.0 V ") {63
t.Fatalf("start niet verticaal: %s", d)64
}65
if !strings.HasSuffix(d, " V 70.0") {66
t.Fatalf("eindigt niet verticaal op het doel: %s", d)67
}68
}@@ -13,10 +13,11 @@ import (
13
13
14
14
// GraphView is de commitgrafiek op de project-overzichtspagina.
15
15
type GraphView struct {
16
Rows []gitgraph.Row
17
Lanes int
18
Width, Height int
19
SVG template.HTML
16
Rows []gitgraph.Row
17
Lanes int
18
Width, Height int
19
TextX, PanelWidth int
20
SVG template.HTML
20
21
}
21
22
22
23
func (s *Server) graphs() *gitgraph.Cache {
@@ -76,11 +77,13 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
76
77
}
77
78
}
78
79
return &GraphView{
79
Rows: rows,
80
Lanes: g.Lanes,
81
Width: g.Width,
82
Height: g.Height,
83
SVG: template.HTML(g.SVG()),
80
Rows: rows,
81
Lanes: g.Lanes,
82
Width: g.Width,
83
Height: g.Height,
84
TextX: g.TextX,
85
PanelWidth: g.PanelWidth,
86
SVG: template.HTML(g.SVG()),
84
87
}
85
88
}
86
89
@@ -13,10 +13,11 @@ import (13
13
14
// GraphView is de commitgrafiek op de project-overzichtspagina.14
// GraphView is de commitgrafiek op de project-overzichtspagina.15
type GraphView struct {15
type GraphView struct {16
Rows []gitgraph.Row16
Rows []gitgraph.Row17
Lanes int17
Lanes int18
Width, Height int18
Width, Height int19
SVG template.HTML19
TextX, PanelWidth int20
SVG template.HTML20
}21
}21
22
22
func (s *Server) graphs() *gitgraph.Cache {23
func (s *Server) graphs() *gitgraph.Cache {@@ -76,11 +77,13 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap76
}77
}77
}78
}78
return &GraphView{79
return &GraphView{79
Rows: rows,80
Rows: rows,80
Lanes: g.Lanes,81
Lanes: g.Lanes,81
Width: g.Width,82
Width: g.Width,82
Height: g.Height,83
Height: g.Height,83
SVG: template.HTML(g.SVG()),84
TextX: g.TextX,85
PanelWidth: g.PanelWidth,86
SVG: template.HTML(g.SVG()),84
}87
}85
}88
}86
89
@@ -32,9 +32,24 @@ func TestOverviewRendersCommitGraph(t *testing.T) {
32
32
if !strings.Contains(page, ">feature<") || !strings.Contains(page, "is-tag") || !strings.Contains(page, ">v1<") {
33
33
t.Fatalf("feature of tag ontbreekt:\n%s", page)
34
34
}
35
if !strings.Contains(page, `stroke="var(--blue)"`) && !strings.Contains(page, `fill="var(--blue)"`) {
35
if !strings.Contains(page, `stroke="var(--blue)"`) {
36
36
t.Fatalf("hoofdbranch is niet blauw:\n%s", page)
37
37
}
38
if !strings.Contains(page, " Q ") || !strings.Contains(page, " H ") {
39
t.Fatalf("verwacht afgeronde 90-graden bochten in de svg:\n%s", page)
40
}
41
if i := strings.Index(page, `class="commitgraph-svg"`); i >= 0 {
42
end := strings.Index(page[i:], "</svg>")
43
if end >= 0 && strings.Contains(page[i:i+end], "<circle") {
44
t.Fatalf("svg mag geen cirkels meer tekenen, de avatar is de knoop")
45
}
46
}
47
if !strings.Contains(page, `data-branch="master"`) {
48
t.Fatalf("gloed-attribuut ontbreekt:\n%s", page)
49
}
50
if !strings.Contains(page, "--graph-w:") {
51
t.Fatalf("paneelbreedte ontbreekt")
52
}
38
53
if strings.Contains(page, "ZgotmplZ") {
39
54
t.Fatalf("css-kleur werd weggestreept:\n%s", page)
40
55
}
@@ -218,9 +233,13 @@ func TestSVGColorsAreSafe(t *testing.T) {
218
233
if !strings.Contains(svg, "var(--blue)") {
219
234
t.Fatalf("blauw ontbreekt: %s", svg)
220
235
}
221
for _, token := range []string{"stroke=\"var(--", "fill=\"var(--"} {
222
if !strings.Contains(svg, token) {
223
t.Fatalf("verwacht %s in %s", token, svg)
224
}
236
if !strings.Contains(svg, "stroke=\"var(--") {
237
t.Fatalf("verwacht stroke in %s", svg)
238
}
239
if strings.Contains(svg, "<circle") {
240
t.Fatalf("geen cirkels in svg: %s", svg)
241
}
242
if !strings.Contains(svg, " Q ") {
243
t.Fatalf("verwacht afgeronde bochten in %s", svg)
225
244
}
226
245
}
@@ -32,9 +32,24 @@ func TestOverviewRendersCommitGraph(t *testing.T) {32
if !strings.Contains(page, ">feature<") || !strings.Contains(page, "is-tag") || !strings.Contains(page, ">v1<") {32
if !strings.Contains(page, ">feature<") || !strings.Contains(page, "is-tag") || !strings.Contains(page, ">v1<") {33
t.Fatalf("feature of tag ontbreekt:\n%s", page)33
t.Fatalf("feature of tag ontbreekt:\n%s", page)34
}34
}35
if !strings.Contains(page, `stroke="var(--blue)"`) && !strings.Contains(page, `fill="var(--blue)"`) {35
if !strings.Contains(page, `stroke="var(--blue)"`) {36
t.Fatalf("hoofdbranch is niet blauw:\n%s", page)36
t.Fatalf("hoofdbranch is niet blauw:\n%s", page)37
}37
}38
if !strings.Contains(page, " Q ") || !strings.Contains(page, " H ") {39
t.Fatalf("verwacht afgeronde 90-graden bochten in de svg:\n%s", page)40
}41
if i := strings.Index(page, `class="commitgraph-svg"`); i >= 0 {42
end := strings.Index(page[i:], "</svg>")43
if end >= 0 && strings.Contains(page[i:i+end], "<circle") {44
t.Fatalf("svg mag geen cirkels meer tekenen, de avatar is de knoop")45
}46
}47
if !strings.Contains(page, `data-branch="master"`) {48
t.Fatalf("gloed-attribuut ontbreekt:\n%s", page)49
}50
if !strings.Contains(page, "--graph-w:") {51
t.Fatalf("paneelbreedte ontbreekt")52
}38
if strings.Contains(page, "ZgotmplZ") {53
if strings.Contains(page, "ZgotmplZ") {39
t.Fatalf("css-kleur werd weggestreept:\n%s", page)54
t.Fatalf("css-kleur werd weggestreept:\n%s", page)40
}55
}@@ -218,9 +233,13 @@ func TestSVGColorsAreSafe(t *testing.T) {218
if !strings.Contains(svg, "var(--blue)") {233
if !strings.Contains(svg, "var(--blue)") {219
t.Fatalf("blauw ontbreekt: %s", svg)234
t.Fatalf("blauw ontbreekt: %s", svg)220
}235
}221
for _, token := range []string{"stroke=\"var(--", "fill=\"var(--"} {236
if !strings.Contains(svg, "stroke=\"var(--") {222
if !strings.Contains(svg, token) {237
t.Fatalf("verwacht stroke in %s", svg)223
t.Fatalf("verwacht %s in %s", token, svg)238
}224
}239
if strings.Contains(svg, "<circle") {240
t.Fatalf("geen cirkels in svg: %s", svg)241
}242
if !strings.Contains(svg, " Q ") {243
t.Fatalf("verwacht afgeronde bochten in %s", svg)225
}244
}226
}245
}@@ -1,6 +1,42 @@
1
1
(function () {
2
function branchMatch(el, name) {
3
if (!name) return false;
4
var raw = el.getAttribute("data-branch") || "";
5
return raw.split(/\s+/).indexOf(name) !== -1;
6
}
7
function applyCommitGraph() {
8
var slot = document.querySelector(".commitgraph-slot");
9
var graph = slot && slot.querySelector(".commitgraph");
10
if (!graph) return;
11
var sel = document.querySelector("select[data-rev]");
12
var name = sel ? sel.value : (graph.getAttribute("data-selected") || "");
13
graph.setAttribute("data-selected", name);
14
graph.querySelectorAll("[data-branch]").forEach(function (el) {
15
el.classList.toggle("is-glow", branchMatch(el, name));
16
});
17
slot.classList.remove("is-right", "is-hidden");
18
var node = graph;
19
var rect = node.getBoundingClientRect();
20
var side = document.querySelector(".sidenav");
21
var leftBound = 8;
22
if (side && getComputedStyle(side).display !== "none") {
23
leftBound = Math.max(leftBound, side.getBoundingClientRect().right + 8);
24
}
25
if (rect.width === 0) return;
26
if (rect.left < leftBound) {
27
slot.classList.add("is-right");
28
rect = node.getBoundingClientRect();
29
if (rect.right > window.innerWidth - 8 || rect.width === 0) {
30
slot.classList.remove("is-right");
31
slot.classList.add("is-hidden");
32
}
33
}
34
}
35
applyCommitGraph();
36
window.addEventListener("resize", applyCommitGraph);
2
37
document.querySelectorAll("select[data-rev]").forEach(function (sel) {
3
38
sel.addEventListener("change", function () {
39
applyCommitGraph();
4
40
var url = new URL(window.location.href);
5
41
url.searchParams.set("rev", sel.value);
6
42
url.searchParams.delete("page");
@@ -1,6 +1,42 @@1
(function () {1
(function () {2
function branchMatch(el, name) {3
if (!name) return false;4
var raw = el.getAttribute("data-branch") || "";5
return raw.split(/\s+/).indexOf(name) !== -1;6
}7
function applyCommitGraph() {8
var slot = document.querySelector(".commitgraph-slot");9
var graph = slot && slot.querySelector(".commitgraph");10
if (!graph) return;11
var sel = document.querySelector("select[data-rev]");12
var name = sel ? sel.value : (graph.getAttribute("data-selected") || "");13
graph.setAttribute("data-selected", name);14
graph.querySelectorAll("[data-branch]").forEach(function (el) {15
el.classList.toggle("is-glow", branchMatch(el, name));16
});17
slot.classList.remove("is-right", "is-hidden");18
var node = graph;19
var rect = node.getBoundingClientRect();20
var side = document.querySelector(".sidenav");21
var leftBound = 8;22
if (side && getComputedStyle(side).display !== "none") {23
leftBound = Math.max(leftBound, side.getBoundingClientRect().right + 8);24
}25
if (rect.width === 0) return;26
if (rect.left < leftBound) {27
slot.classList.add("is-right");28
rect = node.getBoundingClientRect();29
if (rect.right > window.innerWidth - 8 || rect.width === 0) {30
slot.classList.remove("is-right");31
slot.classList.add("is-hidden");32
}33
}34
}35
applyCommitGraph();36
window.addEventListener("resize", applyCommitGraph);2
document.querySelectorAll("select[data-rev]").forEach(function (sel) {37
document.querySelectorAll("select[data-rev]").forEach(function (sel) {3
sel.addEventListener("change", function () {38
sel.addEventListener("change", function () {39
applyCommitGraph();4
var url = new URL(window.location.href);40
var url = new URL(window.location.href);5
url.searchParams.set("rev", sel.value);41
url.searchParams.set("rev", sel.value);6
url.searchParams.delete("page");42
url.searchParams.delete("page");@@ -27,11 +27,13 @@
27
27
--sidebar: 240px;
28
28
--content: 1180px;
29
29
--top-h: 48px;
30
--graph-w: 236px;
31
--graph-gap: 12px;
30
--graph-w: 400px;
31
--graph-gap: 16px;
32
32
--graph-ref-w: 78px;
33
--graph-row: 22px;
34
--graph-lane: 12px;
33
--graph-row: 28px;
34
--graph-lane: 28px;
35
--graph-msg-w: 180px;
36
--graph-node: 18px;
35
37
--graph-0: #0e7490;
36
38
--graph-1: #6f42c1;
37
39
--graph-2: #1f6b3a;
@@ -1529,8 +1531,9 @@ li.rel-asset form.rel-asset-actions { display: inline-flex; align-items: center;
1529
1531
.status.waiting_for_job { background: #fff4e0; color: #8a5a00; }
1530
1532
form.cancelform { display: inline; }
1531
1533
1532
/* Commitgrafiek in de lege ruimte naast de centrale kolom. Buiten de
1533
flow (slotbreedte 0), zodat de bestaande kolom niet verschuift. */
1534
/* Commitgrafiek links van de centrale kolom. In de flow, zodat de
1535
kolom iets naar rechts schuift en de lanes + tekst ruimte krijgen.
1536
Past het links niet, dan hangt hij rechts; anders blijft hij verborgen. */
1534
1537
.commitgraph-slot {
1535
1538
display: none;
1536
1539
position: sticky;
@@ -1542,10 +1545,10 @@ form.cancelform { display: inline; }
1542
1545
}
1543
1546
.commitgraph {
1544
1547
position: relative;
1545
left: calc(-1 * var(--graph-w) - var(--graph-gap) + 8px);
1546
1548
width: var(--graph-w);
1547
1549
max-height: calc(100vh - var(--top-h) - var(--sp-6));
1548
overflow: hidden;
1550
overflow-x: visible;
1551
overflow-y: auto;
1549
1552
font-size: var(--fs-sm);
1550
1553
color: var(--ink);
1551
1554
}
@@ -1559,7 +1562,7 @@ form.cancelform { display: inline; }
1559
1562
}
1560
1563
.commitgraph-row {
1561
1564
display: grid;
1562
grid-template-columns: var(--graph-ref-w) calc(var(--lanes, 1) * var(--graph-lane) + 16px) minmax(0, 1fr);
1565
grid-template-columns: var(--graph-ref-w) calc(var(--lanes, 1) * var(--graph-lane) + 8px) minmax(var(--graph-msg-w), 1fr);
1563
1566
align-items: center;
1564
1567
height: var(--graph-row);
1565
1568
position: relative;
@@ -1579,19 +1582,19 @@ form.cancelform { display: inline; }
1579
1582
}
1580
1583
.commitgraph-ref.is-tag, .commitgraph-ref.tag { border-style: dashed; font-weight: 500; color: var(--muted); }
1581
1584
.commitgraph-ref.is-default { background: var(--blue-soft); }
1582
.commitgraph-node.is-main, .commitgraph-ref.is-main { --c: var(--blue); color: var(--blue); }
1583
.commitgraph-node.c0, .commitgraph-ref.c0 { --c: var(--graph-0); color: var(--graph-0); }
1584
.commitgraph-node.c1, .commitgraph-ref.c1 { --c: var(--graph-1); color: var(--graph-1); }
1585
.commitgraph-node.c2, .commitgraph-ref.c2 { --c: var(--graph-2); color: var(--graph-2); }
1586
.commitgraph-node.c3, .commitgraph-ref.c3 { --c: var(--graph-3); color: var(--graph-3); }
1587
.commitgraph-node.c4, .commitgraph-ref.c4 { --c: var(--graph-4); color: var(--graph-4); }
1588
.commitgraph-node.c5, .commitgraph-ref.c5 { --c: var(--graph-5); color: var(--graph-5); }
1589
.commitgraph-node.c6, .commitgraph-ref.c6 { --c: var(--graph-6); color: var(--graph-6); }
1590
.commitgraph-node.c7, .commitgraph-ref.c7 { --c: var(--graph-7); color: var(--graph-7); }
1585
.commitgraph-node.is-main, .commitgraph-ref.is-main, .commitgraph-svg .is-main { --c: var(--blue); color: var(--blue); }
1586
.commitgraph-node.c0, .commitgraph-ref.c0, .commitgraph-svg .c0 { --c: var(--graph-0); color: var(--graph-0); }
1587
.commitgraph-node.c1, .commitgraph-ref.c1, .commitgraph-svg .c1 { --c: var(--graph-1); color: var(--graph-1); }
1588
.commitgraph-node.c2, .commitgraph-ref.c2, .commitgraph-svg .c2 { --c: var(--graph-2); color: var(--graph-2); }
1589
.commitgraph-node.c3, .commitgraph-ref.c3, .commitgraph-svg .c3 { --c: var(--graph-3); color: var(--graph-3); }
1590
.commitgraph-node.c4, .commitgraph-ref.c4, .commitgraph-svg .c4 { --c: var(--graph-4); color: var(--graph-4); }
1591
.commitgraph-node.c5, .commitgraph-ref.c5, .commitgraph-svg .c5 { --c: var(--graph-5); color: var(--graph-5); }
1592
.commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }
1593
.commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }
1591
1594
.commitgraph-node {
1592
1595
position: absolute;
1593
left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - 8px);
1594
width: 16px; height: 16px; border-radius: 50%;
1596
left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - var(--graph-node) / 2);
1597
width: var(--graph-node); height: var(--graph-node); border-radius: 50%;
1595
1598
z-index: 1;
1596
1599
overflow: hidden;
1597
1600
background: var(--c, var(--blue));
@@ -1601,7 +1604,7 @@ form.cancelform { display: inline; }
1601
1604
text-decoration: none;
1602
1605
box-shadow: 0 0 0 2px var(--paper);
1603
1606
}
1604
.commitgraph-node img { width: 16px; height: 16px; object-fit: cover; display: block; }
1607
.commitgraph-node img { width: var(--graph-node); height: var(--graph-node); object-fit: cover; display: block; }
1605
1608
.commitgraph-msg {
1606
1609
min-width: 0;
1607
1610
color: var(--ink);
@@ -1609,25 +1612,42 @@ form.cancelform { display: inline; }
1609
1612
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
1610
1613
}
1611
1614
.commitgraph-msg:hover { color: var(--blue-deep); text-decoration: underline; }
1612
/* Toon links als er naast de 1180px-kolom ruimte is voor de grafiek.
1613
Beide zijden van de gecentreerde kolom zijn even breed; rechts is
1614
dezelfde drempel, dus links wint altijd als er plek is. */
1615
/* De centrale kolom blijft gecentreerd, dus de vrije ruimte is
1616
aan twee kanten gelijk. De grafiek past links als
1617
(content - 1180) / 2 >= --graph-w + --graph-gap - 8px ≈ 240px,
1618
dus content >= 1660px. Met sidebar (240px) is dat 1900px breedte. */
1619
@container maincol (min-width: 1660px) {
1620
.commitgraph-slot { display: block; }
1615
.commitgraph-svg path.is-glow {
1616
stroke-width: 2.5;
1617
filter: drop-shadow(0 0 2px var(--c, var(--blue)));
1618
}
1619
.commitgraph-node.is-glow {
1620
box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--c, var(--blue));
1621
}
1622
.commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }
1623
/* In de flow links als grafiek + centrale kolom in de contentbak passen.
1624
Met sidebar (240px): viewport >= 240 + graph + gap + 1180.
1625
Zonder: viewport >= graph + gap + 1180. --graph-w is typisch 400px. */
1626
@container maincol (min-width: 1620px) {
1627
.commitgraph-slot { display: block; width: var(--graph-w); }
1628
.commitgraph { margin-right: var(--graph-gap); }
1621
1629
}
1622
@media (min-width: 1900px) {
1623
.frame.with-side .commitgraph-slot { display: block; }
1630
@media (min-width: 1860px) {
1631
.frame.with-side .commitgraph-slot { display: block; width: var(--graph-w); }
1632
.frame.with-side .commitgraph { margin-right: var(--graph-gap); }
1624
1633
}
1625
@media (min-width: 1660px) {
1626
.frame:not(.with-side) .commitgraph-slot { display: block; }
1634
@media (min-width: 1620px) {
1635
.frame:not(.with-side) .commitgraph-slot { display: block; width: var(--graph-w); }
1636
.frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }
1627
1637
}
1628
@media (max-width: 1659px) {
1629
.frame:not(.with-side) .commitgraph-slot { display: none; }
1638
@media (max-width: 1619px) {
1639
.frame:not(.with-side) .commitgraph-slot:not(.is-right) { display: none; }
1640
}
1641
@media (max-width: 1859px) {
1642
.frame.with-side .commitgraph-slot:not(.is-right) { display: none; }
1643
}
1644
.commitgraph-slot.is-right {
1645
display: block;
1646
width: 0;
1647
order: 1;
1630
1648
}
1631
@media (max-width: 1899px) {
1632
.frame.with-side .commitgraph-slot { display: none; }
1649
.commitgraph-slot.is-right .commitgraph {
1650
left: var(--graph-gap);
1651
margin-right: 0;
1633
1652
}
1653
.commitgraph-slot.is-hidden { display: none !important; }
@@ -27,11 +27,13 @@27
--sidebar: 240px;27
--sidebar: 240px;28
--content: 1180px;28
--content: 1180px;29
--top-h: 48px;29
--top-h: 48px;30
--graph-w: 236px;30
--graph-w: 400px;31
--graph-gap: 12px;31
--graph-gap: 16px;32
--graph-ref-w: 78px;32
--graph-ref-w: 78px;33
--graph-row: 22px;33
--graph-row: 28px;34
--graph-lane: 12px;34
--graph-lane: 28px;35
--graph-msg-w: 180px;36
--graph-node: 18px;35
--graph-0: #0e7490;37
--graph-0: #0e7490;36
--graph-1: #6f42c1;38
--graph-1: #6f42c1;37
--graph-2: #1f6b3a;39
--graph-2: #1f6b3a;@@ -1529,8 +1531,9 @@ li.rel-asset form.rel-asset-actions { display: inline-flex; align-items: center;1529
.status.waiting_for_job { background: #fff4e0; color: #8a5a00; }1531
.status.waiting_for_job { background: #fff4e0; color: #8a5a00; }1530
form.cancelform { display: inline; }1532
form.cancelform { display: inline; }1531
1533
1532
/* Commitgrafiek in de lege ruimte naast de centrale kolom. Buiten de1534
/* Commitgrafiek links van de centrale kolom. In de flow, zodat de1533
flow (slotbreedte 0), zodat de bestaande kolom niet verschuift. */1535
kolom iets naar rechts schuift en de lanes + tekst ruimte krijgen.1536
Past het links niet, dan hangt hij rechts; anders blijft hij verborgen. */1534
.commitgraph-slot {1537
.commitgraph-slot {1535
display: none;1538
display: none;1536
position: sticky;1539
position: sticky;@@ -1542,10 +1545,10 @@ form.cancelform { display: inline; }1542
}1545
}1543
.commitgraph {1546
.commitgraph {1544
position: relative;1547
position: relative;1545
left: calc(-1 * var(--graph-w) - var(--graph-gap) + 8px);1546
width: var(--graph-w);1548
width: var(--graph-w);1547
max-height: calc(100vh - var(--top-h) - var(--sp-6));1549
max-height: calc(100vh - var(--top-h) - var(--sp-6));1548
overflow: hidden;1550
overflow-x: visible;1551
overflow-y: auto;1549
font-size: var(--fs-sm);1552
font-size: var(--fs-sm);1550
color: var(--ink);1553
color: var(--ink);1551
}1554
}@@ -1559,7 +1562,7 @@ form.cancelform { display: inline; }1559
}1562
}1560
.commitgraph-row {1563
.commitgraph-row {1561
display: grid;1564
display: grid;1562
grid-template-columns: var(--graph-ref-w) calc(var(--lanes, 1) * var(--graph-lane) + 16px) minmax(0, 1fr);1565
grid-template-columns: var(--graph-ref-w) calc(var(--lanes, 1) * var(--graph-lane) + 8px) minmax(var(--graph-msg-w), 1fr);1563
align-items: center;1566
align-items: center;1564
height: var(--graph-row);1567
height: var(--graph-row);1565
position: relative;1568
position: relative;@@ -1579,19 +1582,19 @@ form.cancelform { display: inline; }1579
}1582
}1580
.commitgraph-ref.is-tag, .commitgraph-ref.tag { border-style: dashed; font-weight: 500; color: var(--muted); }1583
.commitgraph-ref.is-tag, .commitgraph-ref.tag { border-style: dashed; font-weight: 500; color: var(--muted); }1581
.commitgraph-ref.is-default { background: var(--blue-soft); }1584
.commitgraph-ref.is-default { background: var(--blue-soft); }1582
.commitgraph-node.is-main, .commitgraph-ref.is-main { --c: var(--blue); color: var(--blue); }1585
.commitgraph-node.is-main, .commitgraph-ref.is-main, .commitgraph-svg .is-main { --c: var(--blue); color: var(--blue); }1583
.commitgraph-node.c0, .commitgraph-ref.c0 { --c: var(--graph-0); color: var(--graph-0); }1586
.commitgraph-node.c0, .commitgraph-ref.c0, .commitgraph-svg .c0 { --c: var(--graph-0); color: var(--graph-0); }1584
.commitgraph-node.c1, .commitgraph-ref.c1 { --c: var(--graph-1); color: var(--graph-1); }1587
.commitgraph-node.c1, .commitgraph-ref.c1, .commitgraph-svg .c1 { --c: var(--graph-1); color: var(--graph-1); }1585
.commitgraph-node.c2, .commitgraph-ref.c2 { --c: var(--graph-2); color: var(--graph-2); }1588
.commitgraph-node.c2, .commitgraph-ref.c2, .commitgraph-svg .c2 { --c: var(--graph-2); color: var(--graph-2); }1586
.commitgraph-node.c3, .commitgraph-ref.c3 { --c: var(--graph-3); color: var(--graph-3); }1589
.commitgraph-node.c3, .commitgraph-ref.c3, .commitgraph-svg .c3 { --c: var(--graph-3); color: var(--graph-3); }1587
.commitgraph-node.c4, .commitgraph-ref.c4 { --c: var(--graph-4); color: var(--graph-4); }1590
.commitgraph-node.c4, .commitgraph-ref.c4, .commitgraph-svg .c4 { --c: var(--graph-4); color: var(--graph-4); }1588
.commitgraph-node.c5, .commitgraph-ref.c5 { --c: var(--graph-5); color: var(--graph-5); }1591
.commitgraph-node.c5, .commitgraph-ref.c5, .commitgraph-svg .c5 { --c: var(--graph-5); color: var(--graph-5); }1589
.commitgraph-node.c6, .commitgraph-ref.c6 { --c: var(--graph-6); color: var(--graph-6); }1592
.commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }1590
.commitgraph-node.c7, .commitgraph-ref.c7 { --c: var(--graph-7); color: var(--graph-7); }1593
.commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }1591
.commitgraph-node {1594
.commitgraph-node {1592
position: absolute;1595
position: absolute;1593
left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - 8px);1596
left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - var(--graph-node) / 2);1594
width: 16px; height: 16px; border-radius: 50%;1597
width: var(--graph-node); height: var(--graph-node); border-radius: 50%;1595
z-index: 1;1598
z-index: 1;1596
overflow: hidden;1599
overflow: hidden;1597
background: var(--c, var(--blue));1600
background: var(--c, var(--blue));@@ -1601,7 +1604,7 @@ form.cancelform { display: inline; }1601
text-decoration: none;1604
text-decoration: none;1602
box-shadow: 0 0 0 2px var(--paper);1605
box-shadow: 0 0 0 2px var(--paper);1603
}1606
}1604
.commitgraph-node img { width: 16px; height: 16px; object-fit: cover; display: block; }1607
.commitgraph-node img { width: var(--graph-node); height: var(--graph-node); object-fit: cover; display: block; }1605
.commitgraph-msg {1608
.commitgraph-msg {1606
min-width: 0;1609
min-width: 0;1607
color: var(--ink);1610
color: var(--ink);@@ -1609,25 +1612,42 @@ form.cancelform { display: inline; }1609
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;1612
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;1610
}1613
}1611
.commitgraph-msg:hover { color: var(--blue-deep); text-decoration: underline; }1614
.commitgraph-msg:hover { color: var(--blue-deep); text-decoration: underline; }1612
/* Toon links als er naast de 1180px-kolom ruimte is voor de grafiek.1615
.commitgraph-svg path.is-glow {1613
Beide zijden van de gecentreerde kolom zijn even breed; rechts is1616
stroke-width: 2.5;1614
dezelfde drempel, dus links wint altijd als er plek is. */1617
filter: drop-shadow(0 0 2px var(--c, var(--blue)));1615
/* De centrale kolom blijft gecentreerd, dus de vrije ruimte is1618
}1616
aan twee kanten gelijk. De grafiek past links als1619
.commitgraph-node.is-glow {1617
(content - 1180) / 2 >= --graph-w + --graph-gap - 8px ≈ 240px,1620
box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--c, var(--blue));1618
dus content >= 1660px. Met sidebar (240px) is dat 1900px breedte. */1621
}1619
@container maincol (min-width: 1660px) {1622
.commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }1620
.commitgraph-slot { display: block; }1623
/* In de flow links als grafiek + centrale kolom in de contentbak passen.1624
Met sidebar (240px): viewport >= 240 + graph + gap + 1180.1625
Zonder: viewport >= graph + gap + 1180. --graph-w is typisch 400px. */1626
@container maincol (min-width: 1620px) {1627
.commitgraph-slot { display: block; width: var(--graph-w); }1628
.commitgraph { margin-right: var(--graph-gap); }1621
}1629
}1622
@media (min-width: 1900px) {1630
@media (min-width: 1860px) {1623
.frame.with-side .commitgraph-slot { display: block; }1631
.frame.with-side .commitgraph-slot { display: block; width: var(--graph-w); }1632
.frame.with-side .commitgraph { margin-right: var(--graph-gap); }1624
}1633
}1625
@media (min-width: 1660px) {1634
@media (min-width: 1620px) {1626
.frame:not(.with-side) .commitgraph-slot { display: block; }1635
.frame:not(.with-side) .commitgraph-slot { display: block; width: var(--graph-w); }1636
.frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }1627
}1637
}1628
@media (max-width: 1659px) {1638
@media (max-width: 1619px) {1629
.frame:not(.with-side) .commitgraph-slot { display: none; }1639
.frame:not(.with-side) .commitgraph-slot:not(.is-right) { display: none; }1640
}1641
@media (max-width: 1859px) {1642
.frame.with-side .commitgraph-slot:not(.is-right) { display: none; }1643
}1644
.commitgraph-slot.is-right {1645
display: block;1646
width: 0;1647
order: 1;1630
}1648
}1631
@media (max-width: 1899px) {1649
.commitgraph-slot.is-right .commitgraph {1632
.frame.with-side .commitgraph-slot { display: none; }1650
left: var(--graph-gap);1651
margin-right: 0;1633
}1652
}1653
.commitgraph-slot.is-hidden { display: none !important; }@@ -1,14 +1,14 @@
1
1
{{define "commitgraph"}}
2
2
<div class="commitgraph-slot">
3
<aside class="commitgraph" aria-label="{{t "graph.label"}}" style="--lanes: {{.Graph.Lanes}}">
3
<aside class="commitgraph" aria-label="{{t "graph.label"}}" style="--lanes: {{.Graph.Lanes}}; --graph-w: {{.Graph.PanelWidth}}px" data-selected="{{.Rev}}">
4
4
{{.Graph.SVG}}
5
5
<ol class="commitgraph-list">
6
6
{{range .Graph.Rows}}
7
<li class="commitgraph-row" style="--lane: {{.Lane}}">
8
<span class="commitgraph-refs">{{range .Labels}}<span class="commitgraph-ref {{.Kind}}{{if .Default}} is-default{{end}} {{.Class}}" title="{{.Name}}">{{.Name}}</span>{{end}}</span>
7
<li class="commitgraph-row" style="--lane: {{.Lane}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>
8
<span class="commitgraph-refs">{{range .Labels}}<span class="commitgraph-ref {{.Kind}}{{if .Default}} is-default{{end}} {{.Class}}"{{if .Ref}} data-branch="{{.Ref}}" title="{{.Ref}}"{{else}} title="{{.Name}}"{{end}}>{{.Name}}</span>{{end}}</span>
9
9
<span class="commitgraph-lanes" aria-hidden="true"></span>
10
10
<a class="commitgraph-msg" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Subject}}">{{.Subject}}</a>
11
<a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}">{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
11
<a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
12
12
</li>
13
13
{{end}}
14
14
</ol>
@@ -1,14 +1,14 @@1
{{define "commitgraph"}}1
{{define "commitgraph"}}2
<div class="commitgraph-slot">2
<div class="commitgraph-slot">3
<aside class="commitgraph" aria-label="{{t "graph.label"}}" style="--lanes: {{.Graph.Lanes}}">3
<aside class="commitgraph" aria-label="{{t "graph.label"}}" style="--lanes: {{.Graph.Lanes}}; --graph-w: {{.Graph.PanelWidth}}px" data-selected="{{.Rev}}">4
{{.Graph.SVG}}4
{{.Graph.SVG}}5
<ol class="commitgraph-list">5
<ol class="commitgraph-list">6
{{range .Graph.Rows}}6
{{range .Graph.Rows}}7
<li class="commitgraph-row" style="--lane: {{.Lane}}">7
<li class="commitgraph-row" style="--lane: {{.Lane}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>8
<span class="commitgraph-refs">{{range .Labels}}<span class="commitgraph-ref {{.Kind}}{{if .Default}} is-default{{end}} {{.Class}}" title="{{.Name}}">{{.Name}}</span>{{end}}</span>8
<span class="commitgraph-refs">{{range .Labels}}<span class="commitgraph-ref {{.Kind}}{{if .Default}} is-default{{end}} {{.Class}}"{{if .Ref}} data-branch="{{.Ref}}" title="{{.Ref}}"{{else}} title="{{.Name}}"{{end}}>{{.Name}}</span>{{end}}</span>9
<span class="commitgraph-lanes" aria-hidden="true"></span>9
<span class="commitgraph-lanes" aria-hidden="true"></span>10
<a class="commitgraph-msg" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Subject}}">{{.Subject}}</a>10
<a class="commitgraph-msg" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Subject}}">{{.Subject}}</a>11
<a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}">{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>11
<a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>12
</li>12
</li>13
{{end}}13
{{end}}14
</ol>14
</ol>