feat: geef de commitlijst de GitLab-opbouw
Groepeer commits per dag, met filter, identicon, pipeline-icoon en een knop om verder te bladeren. Co-authored-by: tim <tim@timfalken.com>
@@ -123,10 +123,26 @@ type Entry struct {
123
123
124
124
// Log geeft de nieuwste commits.
125
125
func Log(ctx context.Context, gitBin, dir, rev string, limit int) ([]Commit, error) {
126
return LogPage(ctx, gitBin, dir, rev, 0, limit)
127
}
128
129
// LogPage slaat de nieuwste skip commits over en leest daarna hooguit limit commits.
130
func LogPage(ctx context.Context, gitBin, dir, rev string, skip, limit int) ([]Commit, error) {
126
131
if rev == "" {
127
132
rev = "HEAD"
128
133
}
129
out, err := run(ctx, gitBin, nil, "-C", dir, "log", "--format=%H%x1f%an%x1f%ae%x1f%ad%x1f%at%x1f%s%x1f%b%x1e", "--date=short", fmt.Sprintf("-n%d", limit), rev)
134
if limit < 1 {
135
limit = 1
136
}
137
if skip < 0 {
138
skip = 0
139
}
140
args := []string{"-C", dir, "log", "--format=%H%x1f%an%x1f%ae%x1f%ad%x1f%at%x1f%s%x1f%b%x1e", "--date=short", fmt.Sprintf("-n%d", limit)}
141
if skip > 0 {
142
args = append(args, fmt.Sprintf("--skip=%d", skip))
143
}
144
args = append(args, rev)
145
out, err := run(ctx, gitBin, nil, args...)
130
146
if err != nil {
131
147
if strings.Contains(err.Error(), "does not have any commits") || strings.Contains(err.Error(), "bad default revision") || strings.Contains(err.Error(), "ambiguous argument") {
132
148
return nil, nil
@@ -123,10 +123,26 @@ type Entry struct {123
123
124
// Log geeft de nieuwste commits.124
// Log geeft de nieuwste commits.125
func Log(ctx context.Context, gitBin, dir, rev string, limit int) ([]Commit, error) {125
func Log(ctx context.Context, gitBin, dir, rev string, limit int) ([]Commit, error) {126
return LogPage(ctx, gitBin, dir, rev, 0, limit)127
}128
129
// LogPage slaat de nieuwste skip commits over en leest daarna hooguit limit commits.130
func LogPage(ctx context.Context, gitBin, dir, rev string, skip, limit int) ([]Commit, error) {126
if rev == "" {131
if rev == "" {127
rev = "HEAD"132
rev = "HEAD"128
}133
}129
out, err := run(ctx, gitBin, nil, "-C", dir, "log", "--format=%H%x1f%an%x1f%ae%x1f%ad%x1f%at%x1f%s%x1f%b%x1e", "--date=short", fmt.Sprintf("-n%d", limit), rev)134
if limit < 1 {135
limit = 1136
}137
if skip < 0 {138
skip = 0139
}140
args := []string{"-C", dir, "log", "--format=%H%x1f%an%x1f%ae%x1f%ad%x1f%at%x1f%s%x1f%b%x1e", "--date=short", fmt.Sprintf("-n%d", limit)}141
if skip > 0 {142
args = append(args, fmt.Sprintf("--skip=%d", skip))143
}144
args = append(args, rev)145
out, err := run(ctx, gitBin, nil, args...)130
if err != nil {146
if err != nil {131
if strings.Contains(err.Error(), "does not have any commits") || strings.Contains(err.Error(), "bad default revision") || strings.Contains(err.Error(), "ambiguous argument") {147
if strings.Contains(err.Error(), "does not have any commits") || strings.Contains(err.Error(), "bad default revision") || strings.Contains(err.Error(), "ambiguous argument") {132
return nil, nil148
return nil, nil@@ -8,85 +8,113 @@ func init() {
8
8
}
9
9
10
10
var commitEN = map[string]string{
11
"commit.authored": "Authored",
12
"commit.sha": "Hash",
13
"commit.parent": "Parent",
14
"commit.parents": "Parents",
15
"commit.changed": "Changed files",
16
"commit.file.one": "%d file changed",
17
"commit.file.many": "%d files changed",
18
"commit.added": "added",
19
"commit.deleted": "deleted",
20
"commit.renamed": "renamed",
21
"commit.binary": "Binary file",
22
"commit.binaryHint": "The contents of this binary file are not shown.",
23
"commit.show": "Show diff",
24
"commit.hide": "Hide diff",
25
"commit.inline": "Inline",
26
"commit.side": "Side-by-side",
27
"commit.empty": "This commit does not change any files.",
28
"commit.view": "Diff view",
11
"commit.authored": "Authored",
12
"commit.authoredWhen": "authored %s",
13
"commit.search": "Search by message or author",
14
"commit.files": "Browse files at this commit",
15
"commit.expand": "Show commit message",
16
"commit.more": "Load more",
17
"commit.prev": "Previous",
18
"commit.none": "No matching commits.",
19
"commit.sha": "Hash",
20
"commit.parent": "Parent",
21
"commit.parents": "Parents",
22
"commit.changed": "Changed files",
23
"commit.file.one": "%d file changed",
24
"commit.file.many": "%d files changed",
25
"commit.added": "added",
26
"commit.deleted": "deleted",
27
"commit.renamed": "renamed",
28
"commit.binary": "Binary file",
29
"commit.binaryHint": "The contents of this binary file are not shown.",
30
"commit.show": "Show diff",
31
"commit.hide": "Hide diff",
32
"commit.inline": "Inline",
33
"commit.side": "Side-by-side",
34
"commit.empty": "This commit does not change any files.",
35
"commit.view": "Diff view",
29
36
}
30
37
31
38
var commitNL = map[string]string{
32
"commit.authored": "Geschreven",
33
"commit.sha": "Hash",
34
"commit.parent": "Bovenliggende commit",
35
"commit.parents": "Bovenliggende commits",
36
"commit.changed": "Gewijzigde bestanden",
37
"commit.file.one": "%d bestand gewijzigd",
38
"commit.file.many": "%d bestanden gewijzigd",
39
"commit.added": "toegevoegd",
40
"commit.deleted": "verwijderd",
41
"commit.renamed": "hernoemd",
42
"commit.binary": "Binair bestand",
43
"commit.binaryHint": "De inhoud van dit binaire bestand wordt niet getoond.",
44
"commit.show": "Toon diff",
45
"commit.hide": "Verberg diff",
46
"commit.inline": "Onder elkaar",
47
"commit.side": "Naast elkaar",
48
"commit.empty": "Deze commit wijzigt geen bestanden.",
49
"commit.view": "Diffweergave",
39
"commit.authored": "Geschreven",
40
"commit.authoredWhen": "schreef %s",
41
"commit.search": "Zoek op bericht of auteur",
42
"commit.files": "Bestanden bekijken op deze commit",
43
"commit.expand": "Commitbericht tonen",
44
"commit.more": "Meer laden",
45
"commit.prev": "Vorige",
46
"commit.none": "Geen passende commits.",
47
"commit.sha": "Hash",
48
"commit.parent": "Bovenliggende commit",
49
"commit.parents": "Bovenliggende commits",
50
"commit.changed": "Gewijzigde bestanden",
51
"commit.file.one": "%d bestand gewijzigd",
52
"commit.file.many": "%d bestanden gewijzigd",
53
"commit.added": "toegevoegd",
54
"commit.deleted": "verwijderd",
55
"commit.renamed": "hernoemd",
56
"commit.binary": "Binair bestand",
57
"commit.binaryHint": "De inhoud van dit binaire bestand wordt niet getoond.",
58
"commit.show": "Toon diff",
59
"commit.hide": "Verberg diff",
60
"commit.inline": "Onder elkaar",
61
"commit.side": "Naast elkaar",
62
"commit.empty": "Deze commit wijzigt geen bestanden.",
63
"commit.view": "Diffweergave",
50
64
}
51
65
52
66
var commitDE = map[string]string{
53
"commit.authored": "Verfasst",
54
"commit.sha": "Hash",
55
"commit.parent": "Übergeordneter Commit",
56
"commit.parents": "Übergeordnete Commits",
57
"commit.changed": "Geänderte Dateien",
58
"commit.file.one": "%d Datei geändert",
59
"commit.file.many": "%d Dateien geändert",
60
"commit.added": "hinzugefügt",
61
"commit.deleted": "gelöscht",
62
"commit.renamed": "umbenannt",
63
"commit.binary": "Binärdatei",
64
"commit.binaryHint": "Der Inhalt dieser Binärdatei wird nicht angezeigt.",
65
"commit.show": "Diff anzeigen",
66
"commit.hide": "Diff verbergen",
67
"commit.inline": "Untereinander",
68
"commit.side": "Nebeneinander",
69
"commit.empty": "Dieser Commit ändert keine Dateien.",
70
"commit.view": "Diff-Ansicht",
67
"commit.authored": "Verfasst",
68
"commit.authoredWhen": "verfasste %s",
69
"commit.search": "Nach Nachricht oder Autor suchen",
70
"commit.files": "Dateien bei diesem Commit ansehen",
71
"commit.expand": "Commit-Nachricht anzeigen",
72
"commit.more": "Mehr laden",
73
"commit.prev": "Zurück",
74
"commit.none": "Keine passenden Commits.",
75
"commit.sha": "Hash",
76
"commit.parent": "Übergeordneter Commit",
77
"commit.parents": "Übergeordnete Commits",
78
"commit.changed": "Geänderte Dateien",
79
"commit.file.one": "%d Datei geändert",
80
"commit.file.many": "%d Dateien geändert",
81
"commit.added": "hinzugefügt",
82
"commit.deleted": "gelöscht",
83
"commit.renamed": "umbenannt",
84
"commit.binary": "Binärdatei",
85
"commit.binaryHint": "Der Inhalt dieser Binärdatei wird nicht angezeigt.",
86
"commit.show": "Diff anzeigen",
87
"commit.hide": "Diff verbergen",
88
"commit.inline": "Untereinander",
89
"commit.side": "Nebeneinander",
90
"commit.empty": "Dieser Commit ändert keine Dateien.",
91
"commit.view": "Diff-Ansicht",
71
92
}
72
93
73
94
var commitFR = map[string]string{
74
"commit.authored": "Rédigé",
75
"commit.sha": "Empreinte",
76
"commit.parent": "Parent",
77
"commit.parents": "Parents",
78
"commit.changed": "Fichiers modifiés",
79
"commit.file.one": "%d fichier modifié",
80
"commit.file.many": "%d fichiers modifiés",
81
"commit.added": "ajouté",
82
"commit.deleted": "supprimé",
83
"commit.renamed": "renommé",
84
"commit.binary": "Fichier binaire",
85
"commit.binaryHint": "Le contenu de ce fichier binaire n'est pas affiché.",
86
"commit.show": "Afficher le diff",
87
"commit.hide": "Masquer le diff",
88
"commit.inline": "En ligne",
89
"commit.side": "Côte à côte",
90
"commit.empty": "Ce commit ne modifie aucun fichier.",
91
"commit.view": "Affichage du diff",
95
"commit.authored": "Rédigé",
96
"commit.authoredWhen": "a écrit %s",
97
"commit.search": "Chercher par message ou auteur",
98
"commit.files": "Voir les fichiers de ce commit",
99
"commit.expand": "Afficher le message du commit",
100
"commit.more": "Charger la suite",
101
"commit.prev": "Précédent",
102
"commit.none": "Aucun commit correspondant.",
103
"commit.sha": "Empreinte",
104
"commit.parent": "Parent",
105
"commit.parents": "Parents",
106
"commit.changed": "Fichiers modifiés",
107
"commit.file.one": "%d fichier modifié",
108
"commit.file.many": "%d fichiers modifiés",
109
"commit.added": "ajouté",
110
"commit.deleted": "supprimé",
111
"commit.renamed": "renommé",
112
"commit.binary": "Fichier binaire",
113
"commit.binaryHint": "Le contenu de ce fichier binaire n'est pas affiché.",
114
"commit.show": "Afficher le diff",
115
"commit.hide": "Masquer le diff",
116
"commit.inline": "En ligne",
117
"commit.side": "Côte à côte",
118
"commit.empty": "Ce commit ne modifie aucun fichier.",
119
"commit.view": "Affichage du diff",
92
120
}
@@ -8,85 +8,113 @@ func init() {8
}8
}9
9
10
var commitEN = map[string]string{10
var commitEN = map[string]string{11
"commit.authored": "Authored",11
"commit.authored": "Authored",12
"commit.sha": "Hash",12
"commit.authoredWhen": "authored %s",13
"commit.parent": "Parent",13
"commit.search": "Search by message or author",14
"commit.parents": "Parents",14
"commit.files": "Browse files at this commit",15
"commit.changed": "Changed files",15
"commit.expand": "Show commit message",16
"commit.file.one": "%d file changed",16
"commit.more": "Load more",17
"commit.file.many": "%d files changed",17
"commit.prev": "Previous",18
"commit.added": "added",18
"commit.none": "No matching commits.",19
"commit.deleted": "deleted",19
"commit.sha": "Hash",20
"commit.renamed": "renamed",20
"commit.parent": "Parent",21
"commit.binary": "Binary file",21
"commit.parents": "Parents",22
"commit.binaryHint": "The contents of this binary file are not shown.",22
"commit.changed": "Changed files",23
"commit.show": "Show diff",23
"commit.file.one": "%d file changed",24
"commit.hide": "Hide diff",24
"commit.file.many": "%d files changed",25
"commit.inline": "Inline",25
"commit.added": "added",26
"commit.side": "Side-by-side",26
"commit.deleted": "deleted",27
"commit.empty": "This commit does not change any files.",27
"commit.renamed": "renamed",28
"commit.view": "Diff view",28
"commit.binary": "Binary file",29
"commit.binaryHint": "The contents of this binary file are not shown.",30
"commit.show": "Show diff",31
"commit.hide": "Hide diff",32
"commit.inline": "Inline",33
"commit.side": "Side-by-side",34
"commit.empty": "This commit does not change any files.",35
"commit.view": "Diff view",29
}36
}30
37
31
var commitNL = map[string]string{38
var commitNL = map[string]string{32
"commit.authored": "Geschreven",39
"commit.authored": "Geschreven",33
"commit.sha": "Hash",40
"commit.authoredWhen": "schreef %s",34
"commit.parent": "Bovenliggende commit",41
"commit.search": "Zoek op bericht of auteur",35
"commit.parents": "Bovenliggende commits",42
"commit.files": "Bestanden bekijken op deze commit",36
"commit.changed": "Gewijzigde bestanden",43
"commit.expand": "Commitbericht tonen",37
"commit.file.one": "%d bestand gewijzigd",44
"commit.more": "Meer laden",38
"commit.file.many": "%d bestanden gewijzigd",45
"commit.prev": "Vorige",39
"commit.added": "toegevoegd",46
"commit.none": "Geen passende commits.",40
"commit.deleted": "verwijderd",47
"commit.sha": "Hash",41
"commit.renamed": "hernoemd",48
"commit.parent": "Bovenliggende commit",42
"commit.binary": "Binair bestand",49
"commit.parents": "Bovenliggende commits",43
"commit.binaryHint": "De inhoud van dit binaire bestand wordt niet getoond.",50
"commit.changed": "Gewijzigde bestanden",44
"commit.show": "Toon diff",51
"commit.file.one": "%d bestand gewijzigd",45
"commit.hide": "Verberg diff",52
"commit.file.many": "%d bestanden gewijzigd",46
"commit.inline": "Onder elkaar",53
"commit.added": "toegevoegd",47
"commit.side": "Naast elkaar",54
"commit.deleted": "verwijderd",48
"commit.empty": "Deze commit wijzigt geen bestanden.",55
"commit.renamed": "hernoemd",49
"commit.view": "Diffweergave",56
"commit.binary": "Binair bestand",57
"commit.binaryHint": "De inhoud van dit binaire bestand wordt niet getoond.",58
"commit.show": "Toon diff",59
"commit.hide": "Verberg diff",60
"commit.inline": "Onder elkaar",61
"commit.side": "Naast elkaar",62
"commit.empty": "Deze commit wijzigt geen bestanden.",63
"commit.view": "Diffweergave",50
}64
}51
65
52
var commitDE = map[string]string{66
var commitDE = map[string]string{53
"commit.authored": "Verfasst",67
"commit.authored": "Verfasst",54
"commit.sha": "Hash",68
"commit.authoredWhen": "verfasste %s",55
"commit.parent": "Übergeordneter Commit",69
"commit.search": "Nach Nachricht oder Autor suchen",56
"commit.parents": "Übergeordnete Commits",70
"commit.files": "Dateien bei diesem Commit ansehen",57
"commit.changed": "Geänderte Dateien",71
"commit.expand": "Commit-Nachricht anzeigen",58
"commit.file.one": "%d Datei geändert",72
"commit.more": "Mehr laden",59
"commit.file.many": "%d Dateien geändert",73
"commit.prev": "Zurück",60
"commit.added": "hinzugefügt",74
"commit.none": "Keine passenden Commits.",61
"commit.deleted": "gelöscht",75
"commit.sha": "Hash",62
"commit.renamed": "umbenannt",76
"commit.parent": "Übergeordneter Commit",63
"commit.binary": "Binärdatei",77
"commit.parents": "Übergeordnete Commits",64
"commit.binaryHint": "Der Inhalt dieser Binärdatei wird nicht angezeigt.",78
"commit.changed": "Geänderte Dateien",65
"commit.show": "Diff anzeigen",79
"commit.file.one": "%d Datei geändert",66
"commit.hide": "Diff verbergen",80
"commit.file.many": "%d Dateien geändert",67
"commit.inline": "Untereinander",81
"commit.added": "hinzugefügt",68
"commit.side": "Nebeneinander",82
"commit.deleted": "gelöscht",69
"commit.empty": "Dieser Commit ändert keine Dateien.",83
"commit.renamed": "umbenannt",70
"commit.view": "Diff-Ansicht",84
"commit.binary": "Binärdatei",85
"commit.binaryHint": "Der Inhalt dieser Binärdatei wird nicht angezeigt.",86
"commit.show": "Diff anzeigen",87
"commit.hide": "Diff verbergen",88
"commit.inline": "Untereinander",89
"commit.side": "Nebeneinander",90
"commit.empty": "Dieser Commit ändert keine Dateien.",91
"commit.view": "Diff-Ansicht",71
}92
}72
93
73
var commitFR = map[string]string{94
var commitFR = map[string]string{74
"commit.authored": "Rédigé",95
"commit.authored": "Rédigé",75
"commit.sha": "Empreinte",96
"commit.authoredWhen": "a écrit %s",76
"commit.parent": "Parent",97
"commit.search": "Chercher par message ou auteur",77
"commit.parents": "Parents",98
"commit.files": "Voir les fichiers de ce commit",78
"commit.changed": "Fichiers modifiés",99
"commit.expand": "Afficher le message du commit",79
"commit.file.one": "%d fichier modifié",100
"commit.more": "Charger la suite",80
"commit.file.many": "%d fichiers modifiés",101
"commit.prev": "Précédent",81
"commit.added": "ajouté",102
"commit.none": "Aucun commit correspondant.",82
"commit.deleted": "supprimé",103
"commit.sha": "Empreinte",83
"commit.renamed": "renommé",104
"commit.parent": "Parent",84
"commit.binary": "Fichier binaire",105
"commit.parents": "Parents",85
"commit.binaryHint": "Le contenu de ce fichier binaire n'est pas affiché.",106
"commit.changed": "Fichiers modifiés",86
"commit.show": "Afficher le diff",107
"commit.file.one": "%d fichier modifié",87
"commit.hide": "Masquer le diff",108
"commit.file.many": "%d fichiers modifiés",88
"commit.inline": "En ligne",109
"commit.added": "ajouté",89
"commit.side": "Côte à côte",110
"commit.deleted": "supprimé",90
"commit.empty": "Ce commit ne modifie aucun fichier.",111
"commit.renamed": "renommé",91
"commit.view": "Affichage du diff",112
"commit.binary": "Fichier binaire",113
"commit.binaryHint": "Le contenu de ce fichier binaire n'est pas affiché.",114
"commit.show": "Afficher le diff",115
"commit.hide": "Masquer le diff",116
"commit.inline": "En ligne",117
"commit.side": "Côte à côte",118
"commit.empty": "Ce commit ne modifie aucun fichier.",119
"commit.view": "Affichage du diff",92
}120
}@@ -0,0 +1,176 @@
1
package server
2
3
import (
4
"context"
5
"crypto/sha256"
6
"fmt"
7
"html/template"
8
"net/url"
9
"strconv"
10
"strings"
11
"time"
12
13
"gitlab.com/Timfa/bluegit/internal/gitrepo"
14
"gitlab.com/Timfa/bluegit/internal/i18n"
15
)
16
17
const (
18
commitPageSize = 20
19
commitScanCap = 4000
20
)
21
22
func finishCommit(row CommitRow, email, gitAuthor string) CommitRow {
23
if strings.TrimSpace(row.Who) == "" {
24
row.Who = strings.TrimSpace(gitAuthor)
25
}
26
if row.Who == "" {
27
row.Who = row.Author
28
}
29
if row.WhoURL == "" {
30
seed := strings.TrimSpace(email)
31
if seed == "" {
32
seed = row.Who
33
}
34
row.Ident = identiconSVG(seed)
35
}
36
return row
37
}
38
39
func identiconSVG(seed string) template.HTML {
40
sum := sha256.Sum256([]byte(strings.ToLower(strings.TrimSpace(seed))))
41
palette := []string{"#1f6feb", "#146c43", "#9f2d2d", "#8a5a00", "#6f42c1", "#0f766e", "#b45309"}
42
color := palette[int(sum[0])%len(palette)]
43
var b strings.Builder
44
b.WriteString(`<svg class="avatar ident" viewBox="0 0 5 5" aria-hidden="true">`)
45
b.WriteString(`<rect width="5" height="5" fill="#eef2f7"/>`)
46
painted := false
47
i := 1
48
for y := 0; y < 5; y++ {
49
for x := 0; x < 3; x++ {
50
if sum[i]%2 == 0 {
51
fmt.Fprintf(&b, `<rect x="%d" y="%d" width="1" height="1" fill="%s"/>`, x, y, color)
52
if x < 2 {
53
fmt.Fprintf(&b, `<rect x="%d" y="%d" width="1" height="1" fill="%s"/>`, 4-x, y, color)
54
}
55
painted = true
56
}
57
i++
58
}
59
}
60
if !painted {
61
fmt.Fprintf(&b, `<rect x="2" y="2" width="1" height="1" fill="%s"/>`, color)
62
}
63
b.WriteString(`</svg>`)
64
return template.HTML(b.String())
65
}
66
67
func (s *Server) commitWindow(ctx context.Context, dir, rev, query string, skip, limit int) ([]gitrepo.Commit, bool) {
68
if limit < 1 {
69
limit = commitPageSize
70
}
71
if skip < 0 {
72
skip = 0
73
}
74
needle := strings.ToLower(strings.TrimSpace(query))
75
if needle == "" {
76
list, err := gitrepo.LogPage(ctx, s.Git, dir, rev, skip, limit+1)
77
if err != nil || len(list) == 0 {
78
return nil, false
79
}
80
more := len(list) > limit
81
if more {
82
list = list[:limit]
83
}
84
return list, more
85
}
86
var match []gitrepo.Commit
87
scanned := 0
88
for len(match) < skip+limit+1 && scanned < commitScanCap {
89
chunk, err := gitrepo.LogPage(ctx, s.Git, dir, rev, scanned, 80)
90
if err != nil || len(chunk) == 0 {
91
break
92
}
93
for _, c := range chunk {
94
if commitMatches(c, needle) {
95
match = append(match, c)
96
}
97
}
98
scanned += len(chunk)
99
if len(chunk) < 80 {
100
break
101
}
102
}
103
if skip >= len(match) {
104
return nil, false
105
}
106
end := skip + limit
107
more := len(match) > end
108
if end > len(match) {
109
end = len(match)
110
}
111
return match[skip:end], more
112
}
113
114
func commitMatches(c gitrepo.Commit, needle string) bool {
115
return strings.Contains(strings.ToLower(c.Subject), needle) ||
116
strings.Contains(strings.ToLower(c.Body), needle) ||
117
strings.Contains(strings.ToLower(c.Author), needle) ||
118
strings.Contains(strings.ToLower(c.Email), needle)
119
}
120
121
func groupCommitDays(rows []CommitRow, lang i18n.Lang) []CommitDay {
122
var days []CommitDay
123
for _, row := range rows {
124
label := commitDayLabel(lang, row.Date)
125
if n := len(days); n == 0 || days[n-1].Label != label {
126
days = append(days, CommitDay{Label: label})
127
}
128
days[len(days)-1].Items = append(days[len(days)-1].Items, row)
129
}
130
return days
131
}
132
133
func commitDayLabel(lang i18n.Lang, date string) string {
134
at, err := time.Parse("2006-01-02", strings.TrimSpace(date))
135
if err != nil {
136
return date
137
}
138
return i18n.FormatDate(lang, at)
139
}
140
141
func commitPageNum(raw string) int {
142
n, err := strconv.Atoi(strings.TrimSpace(raw))
143
if err != nil || n < 1 {
144
return 1
145
}
146
if n > 1000 {
147
return 1000
148
}
149
return n
150
}
151
152
func clipQuery(raw string) string {
153
q := strings.TrimSpace(raw)
154
if len(q) > 200 {
155
q = q[:200]
156
}
157
return q
158
}
159
160
func commitListURL(repo, rev, query string, page int) string {
161
v := url.Values{}
162
if rev != "" {
163
v.Set("rev", rev)
164
}
165
if query != "" {
166
v.Set("q", query)
167
}
168
if page > 1 {
169
v.Set("page", strconv.Itoa(page))
170
}
171
u := "/" + repo + "/-/commits"
172
if enc := v.Encode(); enc != "" {
173
u += "?" + enc
174
}
175
return u
176
}
@@ -0,0 +1,176 @@1
package server2
3
import (4
"context"5
"crypto/sha256"6
"fmt"7
"html/template"8
"net/url"9
"strconv"10
"strings"11
"time"12
13
"gitlab.com/Timfa/bluegit/internal/gitrepo"14
"gitlab.com/Timfa/bluegit/internal/i18n"15
)16
17
const (18
commitPageSize = 2019
commitScanCap = 400020
)21
22
func finishCommit(row CommitRow, email, gitAuthor string) CommitRow {23
if strings.TrimSpace(row.Who) == "" {24
row.Who = strings.TrimSpace(gitAuthor)25
}26
if row.Who == "" {27
row.Who = row.Author28
}29
if row.WhoURL == "" {30
seed := strings.TrimSpace(email)31
if seed == "" {32
seed = row.Who33
}34
row.Ident = identiconSVG(seed)35
}36
return row37
}38
39
func identiconSVG(seed string) template.HTML {40
sum := sha256.Sum256([]byte(strings.ToLower(strings.TrimSpace(seed))))41
palette := []string{"#1f6feb", "#146c43", "#9f2d2d", "#8a5a00", "#6f42c1", "#0f766e", "#b45309"}42
color := palette[int(sum[0])%len(palette)]43
var b strings.Builder44
b.WriteString(`<svg class="avatar ident" viewBox="0 0 5 5" aria-hidden="true">`)45
b.WriteString(`<rect width="5" height="5" fill="#eef2f7"/>`)46
painted := false47
i := 148
for y := 0; y < 5; y++ {49
for x := 0; x < 3; x++ {50
if sum[i]%2 == 0 {51
fmt.Fprintf(&b, `<rect x="%d" y="%d" width="1" height="1" fill="%s"/>`, x, y, color)52
if x < 2 {53
fmt.Fprintf(&b, `<rect x="%d" y="%d" width="1" height="1" fill="%s"/>`, 4-x, y, color)54
}55
painted = true56
}57
i++58
}59
}60
if !painted {61
fmt.Fprintf(&b, `<rect x="2" y="2" width="1" height="1" fill="%s"/>`, color)62
}63
b.WriteString(`</svg>`)64
return template.HTML(b.String())65
}66
67
func (s *Server) commitWindow(ctx context.Context, dir, rev, query string, skip, limit int) ([]gitrepo.Commit, bool) {68
if limit < 1 {69
limit = commitPageSize70
}71
if skip < 0 {72
skip = 073
}74
needle := strings.ToLower(strings.TrimSpace(query))75
if needle == "" {76
list, err := gitrepo.LogPage(ctx, s.Git, dir, rev, skip, limit+1)77
if err != nil || len(list) == 0 {78
return nil, false79
}80
more := len(list) > limit81
if more {82
list = list[:limit]83
}84
return list, more85
}86
var match []gitrepo.Commit87
scanned := 088
for len(match) < skip+limit+1 && scanned < commitScanCap {89
chunk, err := gitrepo.LogPage(ctx, s.Git, dir, rev, scanned, 80)90
if err != nil || len(chunk) == 0 {91
break92
}93
for _, c := range chunk {94
if commitMatches(c, needle) {95
match = append(match, c)96
}97
}98
scanned += len(chunk)99
if len(chunk) < 80 {100
break101
}102
}103
if skip >= len(match) {104
return nil, false105
}106
end := skip + limit107
more := len(match) > end108
if end > len(match) {109
end = len(match)110
}111
return match[skip:end], more112
}113
114
func commitMatches(c gitrepo.Commit, needle string) bool {115
return strings.Contains(strings.ToLower(c.Subject), needle) ||116
strings.Contains(strings.ToLower(c.Body), needle) ||117
strings.Contains(strings.ToLower(c.Author), needle) ||118
strings.Contains(strings.ToLower(c.Email), needle)119
}120
121
func groupCommitDays(rows []CommitRow, lang i18n.Lang) []CommitDay {122
var days []CommitDay123
for _, row := range rows {124
label := commitDayLabel(lang, row.Date)125
if n := len(days); n == 0 || days[n-1].Label != label {126
days = append(days, CommitDay{Label: label})127
}128
days[len(days)-1].Items = append(days[len(days)-1].Items, row)129
}130
return days131
}132
133
func commitDayLabel(lang i18n.Lang, date string) string {134
at, err := time.Parse("2006-01-02", strings.TrimSpace(date))135
if err != nil {136
return date137
}138
return i18n.FormatDate(lang, at)139
}140
141
func commitPageNum(raw string) int {142
n, err := strconv.Atoi(strings.TrimSpace(raw))143
if err != nil || n < 1 {144
return 1145
}146
if n > 1000 {147
return 1000148
}149
return n150
}151
152
func clipQuery(raw string) string {153
q := strings.TrimSpace(raw)154
if len(q) > 200 {155
q = q[:200]156
}157
return q158
}159
160
func commitListURL(repo, rev, query string, page int) string {161
v := url.Values{}162
if rev != "" {163
v.Set("rev", rev)164
}165
if query != "" {166
v.Set("q", query)167
}168
if page > 1 {169
v.Set("page", strconv.Itoa(page))170
}171
u := "/" + repo + "/-/commits"172
if enc := v.Encode(); enc != "" {173
u += "?" + enc174
}175
return u176
}@@ -0,0 +1,153 @@
1
package server
2
3
import (
4
"context"
5
"net/http"
6
"net/http/cookiejar"
7
"net/http/httptest"
8
"net/url"
9
"os"
10
"os/exec"
11
"path/filepath"
12
"strings"
13
"testing"
14
15
"gitlab.com/Timfa/bluegit/internal/auth"
16
"gitlab.com/Timfa/bluegit/internal/config"
17
"gitlab.com/Timfa/bluegit/internal/store"
18
)
19
20
func TestCommitList(t *testing.T) {
21
if _, err := exec.LookPath("git"); err != nil {
22
t.Skip("git ontbreekt")
23
}
24
storage := t.TempDir()
25
st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
26
if err != nil {
27
t.Fatal(err)
28
}
29
t.Cleanup(func() { _ = st.Close() })
30
cfg := config.Config{
31
BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
32
Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
33
Git: config.Git{Binary: "git", DefaultBranch: "master"},
34
}
35
srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
36
ts := httptest.NewServer(srv.Handler())
37
t.Cleanup(ts.Close)
38
jar, _ := cookiejar.New(nil)
39
tim := &http.Client{Jar: jar}
40
page := read(t, mustGet(t, tim, ts.URL+"/login"))
41
page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
42
"csrf": {csrfOf(t, page)}, "name": {"logboek"}, "visibility": {"public"},
43
}))
44
page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{
45
"csrf": {csrfOf(t, page)}, "name": {"laptop"},
46
}))
47
token := between(page, `<p class="code">`, "</p>")
48
remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/logboek.git"
49
work := t.TempDir()
50
gitPrep(t, work)
51
writeFile(t, filepath.Join(work, "note.txt"), "oud\n")
52
git(t, work, "add", "note.txt")
53
gitAs(t, work, "Zoeker", "zoeker@example.com", "2026-09-01T12:00:00Z", "oudste")
54
writeFile(t, filepath.Join(work, "note.txt"), "sept\n")
55
git(t, work, "add", "note.txt")
56
gitBody(t, work, "Zoeker", "zoeker@example.com", "2026-09-02T12:00:00Z", "september-commit", "tweede regel van de body")
57
for i := 2; i <= 20; i++ {
58
writeFile(t, filepath.Join(work, "note.txt"), strings.Repeat("x", i)+"\n")
59
git(t, work, "add", "note.txt")
60
msg := "c02"
61
when := "2026-10-23T12:00:00Z"
62
if i == 20 {
63
msg = "nieuwste"
64
} else {
65
msg = "c" + two(i)
66
}
67
gitAs(t, work, "tim", "tim@users.git.timfalken.com", when, msg)
68
}
69
git(t, work, "remote", "add", "origin", remote)
70
git(t, work, "push", "-u", "origin", "master")
71
head := revHEAD(t, work)
72
73
page = read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits"))
74
for _, want := range []string{
75
"Commits", "logboek", `name="rev"`, `value="master"`,
76
"Search by message or author", "23 October 2026", "2 September 2026",
77
"nieuwste", "september-commit", "authored",
78
`class="avatar ident"`, "Zoeker",
79
`data-copy="` + head + `"`,
80
`/-/commit/` + head,
81
`/-/tree?rev=` + head,
82
`data-commit-toggle`,
83
"tweede regel van de body",
84
"Load more",
85
} {
86
if !strings.Contains(page, want) {
87
t.Fatalf("commitlijst mist %q", want)
88
}
89
}
90
if strings.Contains(page, "Unverified") || strings.Contains(page, "oudste") {
91
t.Fatalf("eerste pagina:\n%s", page)
92
}
93
if !strings.Contains(page, ">Load more</a>") && !strings.Contains(page, "page=2") {
94
t.Fatalf("geen volgende pagina:\n%s", page)
95
}
96
97
filtered := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?q=september-commit"))
98
if !strings.Contains(filtered, "september-commit") || strings.Contains(filtered, ">nieuwste</a>") || !strings.Contains(filtered, "2 September 2026") {
99
t.Fatalf("filter op bericht:\n%s", filtered)
100
}
101
byAuthor := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?q=Zoeker"))
102
if !strings.Contains(byAuthor, "september-commit") || !strings.Contains(byAuthor, "oudste") || strings.Contains(byAuthor, ">nieuwste</a>") {
103
t.Fatalf("filter op auteur:\n%s", byAuthor)
104
}
105
none := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?q=geen-treffer"))
106
if !strings.Contains(none, "No matching commits.") {
107
t.Fatalf("lege filter:\n%s", none)
108
}
109
110
next := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?page=2"))
111
if !strings.Contains(next, ">oudste</a>") || strings.Contains(next, ">nieuwste</a>") || !strings.Contains(next, "Previous") || strings.Contains(next, ">Load more</a>") {
112
t.Fatalf("pagina 2:\n%s", next)
113
}
114
115
repo, err := st.RepoByPath(context.Background(), "tim", "logboek")
116
if err != nil {
117
t.Fatal(err)
118
}
119
if _, err := st.CreatePipeline(context.Background(), repo.ID, head, "master", "push", "tim", "nieuwste", []store.NewJob{{
120
Name: "build", Stage: "test", Script: "true",
121
}}); err != nil {
122
t.Fatal(err)
123
}
124
withPipe := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits"))
125
if !strings.Contains(withPipe, `class="status pending markonly"`) || !strings.Contains(withPipe, "/-/pipelines/") {
126
t.Fatalf("pipeline-icoon:\n%s", withPipe)
127
}
128
}
129
130
func two(n int) string {
131
if n < 10 {
132
return "0" + string(rune('0'+n))
133
}
134
return string(rune('0'+n/10)) + string(rune('0'+n%10))
135
}
136
137
func gitBody(t *testing.T, dir, name, email, date, subject, body string) {
138
t.Helper()
139
cmd := exec.Command("git", "commit", "-m", subject, "-m", body)
140
cmd.Dir = dir
141
cmd.Env = append(os.Environ(),
142
"GIT_AUTHOR_NAME="+name,
143
"GIT_AUTHOR_EMAIL="+email,
144
"GIT_COMMITTER_NAME="+name,
145
"GIT_COMMITTER_EMAIL="+email,
146
"GIT_AUTHOR_DATE="+date,
147
"GIT_COMMITTER_DATE="+date,
148
)
149
out, err := cmd.CombinedOutput()
150
if err != nil {
151
t.Fatalf("commit %s: %v\n%s", subject, err, out)
152
}
153
}
@@ -0,0 +1,153 @@1
package server2
3
import (4
"context"5
"net/http"6
"net/http/cookiejar"7
"net/http/httptest"8
"net/url"9
"os"10
"os/exec"11
"path/filepath"12
"strings"13
"testing"14
15
"gitlab.com/Timfa/bluegit/internal/auth"16
"gitlab.com/Timfa/bluegit/internal/config"17
"gitlab.com/Timfa/bluegit/internal/store"18
)19
20
func TestCommitList(t *testing.T) {21
if _, err := exec.LookPath("git"); err != nil {22
t.Skip("git ontbreekt")23
}24
storage := t.TempDir()25
st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())26
if err != nil {27
t.Fatal(err)28
}29
t.Cleanup(func() { _ = st.Close() })30
cfg := config.Config{31
BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,32
Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},33
Git: config.Git{Binary: "git", DefaultBranch: "master"},34
}35
srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}36
ts := httptest.NewServer(srv.Handler())37
t.Cleanup(ts.Close)38
jar, _ := cookiejar.New(nil)39
tim := &http.Client{Jar: jar}40
page := read(t, mustGet(t, tim, ts.URL+"/login"))41
page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{42
"csrf": {csrfOf(t, page)}, "name": {"logboek"}, "visibility": {"public"},43
}))44
page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{45
"csrf": {csrfOf(t, page)}, "name": {"laptop"},46
}))47
token := between(page, `<p class="code">`, "</p>")48
remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/logboek.git"49
work := t.TempDir()50
gitPrep(t, work)51
writeFile(t, filepath.Join(work, "note.txt"), "oud\n")52
git(t, work, "add", "note.txt")53
gitAs(t, work, "Zoeker", "zoeker@example.com", "2026-09-01T12:00:00Z", "oudste")54
writeFile(t, filepath.Join(work, "note.txt"), "sept\n")55
git(t, work, "add", "note.txt")56
gitBody(t, work, "Zoeker", "zoeker@example.com", "2026-09-02T12:00:00Z", "september-commit", "tweede regel van de body")57
for i := 2; i <= 20; i++ {58
writeFile(t, filepath.Join(work, "note.txt"), strings.Repeat("x", i)+"\n")59
git(t, work, "add", "note.txt")60
msg := "c02"61
when := "2026-10-23T12:00:00Z"62
if i == 20 {63
msg = "nieuwste"64
} else {65
msg = "c" + two(i)66
}67
gitAs(t, work, "tim", "tim@users.git.timfalken.com", when, msg)68
}69
git(t, work, "remote", "add", "origin", remote)70
git(t, work, "push", "-u", "origin", "master")71
head := revHEAD(t, work)72
73
page = read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits"))74
for _, want := range []string{75
"Commits", "logboek", `name="rev"`, `value="master"`,76
"Search by message or author", "23 October 2026", "2 September 2026",77
"nieuwste", "september-commit", "authored",78
`class="avatar ident"`, "Zoeker",79
`data-copy="` + head + `"`,80
`/-/commit/` + head,81
`/-/tree?rev=` + head,82
`data-commit-toggle`,83
"tweede regel van de body",84
"Load more",85
} {86
if !strings.Contains(page, want) {87
t.Fatalf("commitlijst mist %q", want)88
}89
}90
if strings.Contains(page, "Unverified") || strings.Contains(page, "oudste") {91
t.Fatalf("eerste pagina:\n%s", page)92
}93
if !strings.Contains(page, ">Load more</a>") && !strings.Contains(page, "page=2") {94
t.Fatalf("geen volgende pagina:\n%s", page)95
}96
97
filtered := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?q=september-commit"))98
if !strings.Contains(filtered, "september-commit") || strings.Contains(filtered, ">nieuwste</a>") || !strings.Contains(filtered, "2 September 2026") {99
t.Fatalf("filter op bericht:\n%s", filtered)100
}101
byAuthor := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?q=Zoeker"))102
if !strings.Contains(byAuthor, "september-commit") || !strings.Contains(byAuthor, "oudste") || strings.Contains(byAuthor, ">nieuwste</a>") {103
t.Fatalf("filter op auteur:\n%s", byAuthor)104
}105
none := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?q=geen-treffer"))106
if !strings.Contains(none, "No matching commits.") {107
t.Fatalf("lege filter:\n%s", none)108
}109
110
next := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits?page=2"))111
if !strings.Contains(next, ">oudste</a>") || strings.Contains(next, ">nieuwste</a>") || !strings.Contains(next, "Previous") || strings.Contains(next, ">Load more</a>") {112
t.Fatalf("pagina 2:\n%s", next)113
}114
115
repo, err := st.RepoByPath(context.Background(), "tim", "logboek")116
if err != nil {117
t.Fatal(err)118
}119
if _, err := st.CreatePipeline(context.Background(), repo.ID, head, "master", "push", "tim", "nieuwste", []store.NewJob{{120
Name: "build", Stage: "test", Script: "true",121
}}); err != nil {122
t.Fatal(err)123
}124
withPipe := read(t, mustGet(t, tim, ts.URL+"/tim/logboek/-/commits"))125
if !strings.Contains(withPipe, `class="status pending markonly"`) || !strings.Contains(withPipe, "/-/pipelines/") {126
t.Fatalf("pipeline-icoon:\n%s", withPipe)127
}128
}129
130
func two(n int) string {131
if n < 10 {132
return "0" + string(rune('0'+n))133
}134
return string(rune('0'+n/10)) + string(rune('0'+n%10))135
}136
137
func gitBody(t *testing.T, dir, name, email, date, subject, body string) {138
t.Helper()139
cmd := exec.Command("git", "commit", "-m", subject, "-m", body)140
cmd.Dir = dir141
cmd.Env = append(os.Environ(),142
"GIT_AUTHOR_NAME="+name,143
"GIT_AUTHOR_EMAIL="+email,144
"GIT_COMMITTER_NAME="+name,145
"GIT_COMMITTER_EMAIL="+email,146
"GIT_AUTHOR_DATE="+date,147
"GIT_COMMITTER_DATE="+date,148
)149
out, err := cmd.CombinedOutput()150
if err != nil {151
t.Fatalf("commit %s: %v\n%s", subject, err, out)152
}153
}@@ -133,10 +133,15 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P
133
133
}
134
134
if u, ok := s.userForEmail(ctx, c.Email, cache, miss); ok {
135
135
row.Author = u.Username
136
row.UserURL = "/users/" + u.Username
136
row.Who = strings.TrimSpace(u.DisplayName)
137
if row.Who == "" {
138
row.Who = u.Username
139
}
140
row.WhoURL = "/users/" + u.Username
141
row.UserURL = row.WhoURL
137
142
row.Avatar = u.AvatarURL
138
143
row.Initial = initialOf(u.Username)
139
return row
144
return finishCommit(row, c.Email, c.Author)
140
145
}
141
146
if pusher.UserID != 0 && pusher.Username != "" {
142
147
row.Author = pusher.Username
@@ -149,7 +154,7 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P
149
154
row.PushedBy = pusher.Username
150
155
}
151
156
}
152
return row
157
return finishCommit(row, c.Email, c.Author)
153
158
}
154
159
155
160
func (s *Server) userForEmail(ctx context.Context, email string, cache map[string]store.User, miss map[string]bool) (store.User, bool) {
@@ -133,10 +133,15 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P133
}133
}134
if u, ok := s.userForEmail(ctx, c.Email, cache, miss); ok {134
if u, ok := s.userForEmail(ctx, c.Email, cache, miss); ok {135
row.Author = u.Username135
row.Author = u.Username136
row.UserURL = "/users/" + u.Username136
row.Who = strings.TrimSpace(u.DisplayName)137
if row.Who == "" {138
row.Who = u.Username139
}140
row.WhoURL = "/users/" + u.Username141
row.UserURL = row.WhoURL137
row.Avatar = u.AvatarURL142
row.Avatar = u.AvatarURL138
row.Initial = initialOf(u.Username)143
row.Initial = initialOf(u.Username)139
return row144
return finishCommit(row, c.Email, c.Author)140
}145
}141
if pusher.UserID != 0 && pusher.Username != "" {146
if pusher.UserID != 0 && pusher.Username != "" {142
row.Author = pusher.Username147
row.Author = pusher.Username@@ -149,7 +154,7 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P149
row.PushedBy = pusher.Username154
row.PushedBy = pusher.Username150
}155
}151
}156
}152
return row157
return finishCommit(row, c.Email, c.Author)153
}158
}154
159
155
func (s *Server) userForEmail(ctx context.Context, email string, cache map[string]store.User, miss map[string]bool) (store.User, bool) {160
func (s *Server) userForEmail(ctx context.Context, email string, cache map[string]store.User, miss map[string]bool) (store.User, bool) {@@ -129,9 +129,25 @@ func (s *Server) commits(w http.ResponseWriter, r *http.Request) {
129
129
}
130
130
v := s.repoView(w, r, repo, role, "title.commits")
131
131
v.Page = "commits"
132
v.Wide = true
133
v.Query = clipQuery(r.URL.Query().Get("q"))
132
134
dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
133
list, _ := gitrepo.Log(r.Context(), s.Git, dir, v.Rev, 50)
134
v.Commits = s.presentCommits(r.Context(), repo.ID, list, i18n.Parse(v.Lang))
135
s.branchList(r, &v, dir)
136
page := commitPageNum(r.URL.Query().Get("page"))
137
list, more := s.commitWindow(r.Context(), dir, v.Rev, v.Query, (page-1)*commitPageSize, commitPageSize)
138
lang := i18n.Parse(v.Lang)
139
rows := s.presentCommits(r.Context(), repo.ID, list, lang)
140
for i := range rows {
141
s.attachHeadPipeline(r.Context(), repo, &rows[i], lang)
142
}
143
v.Commits = rows
144
v.CommitDays = groupCommitDays(rows, lang)
145
if page > 1 {
146
v.CommitPrev = commitListURL(repo.FullPath(), v.Rev, v.Query, page-1)
147
}
148
if more {
149
v.CommitNext = commitListURL(repo.FullPath(), v.Rev, v.Query, page+1)
150
}
135
151
s.render(w, "commits", v)
136
152
}
137
153
@@ -129,9 +129,25 @@ func (s *Server) commits(w http.ResponseWriter, r *http.Request) {129
}129
}130
v := s.repoView(w, r, repo, role, "title.commits")130
v := s.repoView(w, r, repo, role, "title.commits")131
v.Page = "commits"131
v.Page = "commits"132
v.Wide = true133
v.Query = clipQuery(r.URL.Query().Get("q"))132
dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)134
dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)133
list, _ := gitrepo.Log(r.Context(), s.Git, dir, v.Rev, 50)135
s.branchList(r, &v, dir)134
v.Commits = s.presentCommits(r.Context(), repo.ID, list, i18n.Parse(v.Lang))136
page := commitPageNum(r.URL.Query().Get("page"))137
list, more := s.commitWindow(r.Context(), dir, v.Rev, v.Query, (page-1)*commitPageSize, commitPageSize)138
lang := i18n.Parse(v.Lang)139
rows := s.presentCommits(r.Context(), repo.ID, list, lang)140
for i := range rows {141
s.attachHeadPipeline(r.Context(), repo, &rows[i], lang)142
}143
v.Commits = rows144
v.CommitDays = groupCommitDays(rows, lang)145
if page > 1 {146
v.CommitPrev = commitListURL(repo.FullPath(), v.Rev, v.Query, page-1)147
}148
if more {149
v.CommitNext = commitListURL(repo.FullPath(), v.Rev, v.Query, page+1)150
}135
s.render(w, "commits", v)151
s.render(w, "commits", v)136
}152
}137
153
@@ -516,6 +516,9 @@ type View struct {
516
516
CanComment bool
517
517
CanApply bool
518
518
Commits []CommitRow
519
CommitDays []CommitDay
520
CommitPrev string
521
CommitNext string
519
522
Commit *CommitRow
520
523
CommitDiff *CommitDiff
521
524
Entries []EntryRow
@@ -706,12 +709,19 @@ type CodeLine struct {
706
709
// Author is de gekoppelde gebruiker, of anders de ruwe git-naam.
707
710
// RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.
708
711
type CommitRow struct {
709
SHA, Short, Author, Date, Subject, Body, When string
710
UserURL, Avatar, Initial, RawName, PushedBy string
711
PipeID int64
712
PipeStatus, PipeLabel, PipeDuration string
713
PipeStages []StageView
714
PipeLive bool
712
SHA, Short, Author, Who, Date, Subject, Body, When string
713
UserURL, WhoURL, Avatar, Initial, RawName, PushedBy string
714
Ident template.HTML
715
PipeID int64
716
PipeStatus, PipeLabel, PipeDuration string
717
PipeStages []StageView
718
PipeLive bool
719
}
720
721
// CommitDay is één dag op de commitlijst, nieuwste dag eerst.
722
type CommitDay struct {
723
Label string
724
Items []CommitRow
715
725
}
716
726
717
727
// EntryRow is een bestand of map.
@@ -516,6 +516,9 @@ type View struct {516
CanComment bool516
CanComment bool517
CanApply bool517
CanApply bool518
Commits []CommitRow518
Commits []CommitRow519
CommitDays []CommitDay520
CommitPrev string521
CommitNext string519
Commit *CommitRow522
Commit *CommitRow520
CommitDiff *CommitDiff523
CommitDiff *CommitDiff521
Entries []EntryRow524
Entries []EntryRow@@ -706,12 +709,19 @@ type CodeLine struct {706
// Author is de gekoppelde gebruiker, of anders de ruwe git-naam.709
// Author is de gekoppelde gebruiker, of anders de ruwe git-naam.707
// RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.710
// RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.708
type CommitRow struct {711
type CommitRow struct {709
SHA, Short, Author, Date, Subject, Body, When string712
SHA, Short, Author, Who, Date, Subject, Body, When string710
UserURL, Avatar, Initial, RawName, PushedBy string713
UserURL, WhoURL, Avatar, Initial, RawName, PushedBy string711
PipeID int64714
Ident template.HTML712
PipeStatus, PipeLabel, PipeDuration string715
PipeID int64713
PipeStages []StageView716
PipeStatus, PipeLabel, PipeDuration string714
PipeLive bool717
PipeStages []StageView718
PipeLive bool719
}720
721
// CommitDay is één dag op de commitlijst, nieuwste dag eerst.722
type CommitDay struct {723
Label string724
Items []CommitRow715
}725
}716
726
717
// EntryRow is een bestand of map.727
// EntryRow is een bestand of map.@@ -0,0 +1,19 @@
1
(function () {
2
document.querySelectorAll("[data-commit-toggle]").forEach(function (btn) {
3
btn.addEventListener("click", function () {
4
var card = btn.closest("[data-commit]");
5
var msg = card && card.querySelector(".cmsg");
6
if (!msg) {
7
return;
8
}
9
var open = msg.hasAttribute("hidden");
10
if (open) {
11
msg.removeAttribute("hidden");
12
} else {
13
msg.setAttribute("hidden", "");
14
}
15
btn.classList.toggle("open", open);
16
btn.setAttribute("aria-expanded", open ? "true" : "false");
17
});
18
});
19
})();
@@ -0,0 +1,19 @@1
(function () {2
document.querySelectorAll("[data-commit-toggle]").forEach(function (btn) {3
btn.addEventListener("click", function () {4
var card = btn.closest("[data-commit]");5
var msg = card && card.querySelector(".cmsg");6
if (!msg) {7
return;8
}9
var open = msg.hasAttribute("hidden");10
if (open) {11
msg.removeAttribute("hidden");12
} else {13
msg.setAttribute("hidden", "");14
}15
btn.classList.toggle("open", open);16
btn.setAttribute("aria-expanded", open ? "true" : "false");17
});18
});19
})();@@ -3,6 +3,7 @@
3
3
sel.addEventListener("change", function () {
4
4
var url = new URL(window.location.href);
5
5
url.searchParams.set("rev", sel.value);
6
url.searchParams.delete("page");
6
7
window.location = url.toString();
7
8
});
8
9
});
@@ -3,6 +3,7 @@3
sel.addEventListener("change", function () {3
sel.addEventListener("change", function () {4
var url = new URL(window.location.href);4
var url = new URL(window.location.href);5
url.searchParams.set("rev", sel.value);5
url.searchParams.set("rev", sel.value);6
url.searchParams.delete("page");6
window.location = url.toString();7
window.location = url.toString();7
});8
});8
});9
});@@ -234,7 +234,72 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
234
234
width: 32px; height: 32px; border-radius: 50%; background: #d5e0ee; color: var(--ink);
235
235
display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; flex: none;
236
236
}
237
img.avatar { object-fit: cover; display: block; }
237
img.avatar, svg.avatar.ident { object-fit: cover; display: block; }
238
.clogref { display: flex; align-items: center; gap: 0.7rem; margin: 0 0 0.35rem; }
239
.clogpick {
240
display: inline-flex; align-items: center; gap: 0.35rem;
241
border: 1px solid var(--line); border-radius: 8px; background: white;
242
padding: 0 0.45rem 0 0.55rem; min-height: 32px;
243
}
244
.clogpick select {
245
border: 0; background: transparent; min-height: 30px; width: auto;
246
padding: 0 1.1rem 0 0; font: inherit;
247
}
248
.clogrepo { font-weight: 650; color: var(--ink); text-decoration: none; }
249
.clog h1 { margin: 0.15rem 0 0.75rem; font-size: 1.7rem; }
250
.clogsearch {
251
display: flex; align-items: center; gap: 0.4rem; margin: 0 0 1rem;
252
border: 1px solid var(--line); border-radius: 8px; background: white;
253
min-height: 36px; padding: 0 0.55rem;
254
}
255
.clogsearch input { border: 0; flex: 1; min-height: 0; padding: 0; background: transparent; width: auto; }
256
.clogsearch input:focus { outline: none; }
257
.clogsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
258
.clogsearch button { background: transparent; color: var(--muted); border: 0; min-height: 0; width: 28px; padding: 0; }
259
.cday { position: relative; margin: 0 0 0.35rem; padding-left: 1.35rem; }
260
.cday::before {
261
content: ""; position: absolute; left: 0.22rem; top: 0.7rem; bottom: 0.2rem;
262
width: 2px; background: #d8dee6;
263
}
264
.cday h2 { position: relative; margin: 0.35rem 0 0.55rem; font-size: 0.95rem; }
265
.cday h2::before {
266
content: ""; position: absolute; left: -1.28rem; top: 0.28rem;
267
width: 10px; height: 10px; border-radius: 50%; background: white;
268
box-shadow: inset 0 0 0 2px #8b95a1;
269
}
270
.ccard {
271
display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem;
272
background: white; border: 1px solid var(--line); border-radius: 10px;
273
padding: 0.65rem 0.8rem; margin: 0 0 0.55rem;
274
}
275
.cmain { flex: 1; min-width: 0; }
276
.csubject { display: block; font-weight: 700; color: var(--ink); text-decoration: none; }
277
.csubject:hover { color: var(--blue-deep); }
278
.cby { margin: 0.12rem 0 0; color: var(--muted); font-size: var(--fs-sm); }
279
.cby a { color: inherit; }
280
.cacts { display: flex; align-items: center; gap: 0.3rem; flex: none; }
281
.cacts code { font-family: var(--mono); color: var(--muted); font-size: 0.85rem; }
282
a.status.markonly { padding: 0; background: transparent; min-height: 0; }
283
.cchev::before {
284
content: ""; width: 0.38rem; height: 0.38rem;
285
border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
286
transform: translateY(-1px) rotate(45deg);
287
}
288
.cchev.open::before { transform: translateY(1px) rotate(225deg); }
289
.cmsg {
290
flex-basis: 100%; margin: 0.15rem 0 0; padding-top: 0.45rem;
291
border-top: 1px solid var(--line); white-space: pre-wrap;
292
}
293
.cmsg[hidden] { display: none !important; }
294
.clogmore { display: flex; gap: 0.6rem; margin: 0.4rem 0 0.6rem; }
295
.clogmore a {
296
display: inline-flex; align-items: center; min-height: var(--control-h);
297
padding: 0 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);
298
background: white; color: var(--ink); text-decoration: none;
299
}
300
@media (max-width: 800px) {
301
.cacts { width: 100%; justify-content: flex-end; }
302
}
238
303
.avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; }
239
304
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; }
240
305
a.avatarlink { display: inline-grid; color: inherit; text-decoration: none; line-height: 0; }
@@ -234,7 +234,72 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px234
width: 32px; height: 32px; border-radius: 50%; background: #d5e0ee; color: var(--ink);234
width: 32px; height: 32px; border-radius: 50%; background: #d5e0ee; color: var(--ink);235
display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; flex: none;235
display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; flex: none;236
}236
}237
img.avatar { object-fit: cover; display: block; }237
img.avatar, svg.avatar.ident { object-fit: cover; display: block; }238
.clogref { display: flex; align-items: center; gap: 0.7rem; margin: 0 0 0.35rem; }239
.clogpick {240
display: inline-flex; align-items: center; gap: 0.35rem;241
border: 1px solid var(--line); border-radius: 8px; background: white;242
padding: 0 0.45rem 0 0.55rem; min-height: 32px;243
}244
.clogpick select {245
border: 0; background: transparent; min-height: 30px; width: auto;246
padding: 0 1.1rem 0 0; font: inherit;247
}248
.clogrepo { font-weight: 650; color: var(--ink); text-decoration: none; }249
.clog h1 { margin: 0.15rem 0 0.75rem; font-size: 1.7rem; }250
.clogsearch {251
display: flex; align-items: center; gap: 0.4rem; margin: 0 0 1rem;252
border: 1px solid var(--line); border-radius: 8px; background: white;253
min-height: 36px; padding: 0 0.55rem;254
}255
.clogsearch input { border: 0; flex: 1; min-height: 0; padding: 0; background: transparent; width: auto; }256
.clogsearch input:focus { outline: none; }257
.clogsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }258
.clogsearch button { background: transparent; color: var(--muted); border: 0; min-height: 0; width: 28px; padding: 0; }259
.cday { position: relative; margin: 0 0 0.35rem; padding-left: 1.35rem; }260
.cday::before {261
content: ""; position: absolute; left: 0.22rem; top: 0.7rem; bottom: 0.2rem;262
width: 2px; background: #d8dee6;263
}264
.cday h2 { position: relative; margin: 0.35rem 0 0.55rem; font-size: 0.95rem; }265
.cday h2::before {266
content: ""; position: absolute; left: -1.28rem; top: 0.28rem;267
width: 10px; height: 10px; border-radius: 50%; background: white;268
box-shadow: inset 0 0 0 2px #8b95a1;269
}270
.ccard {271
display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem;272
background: white; border: 1px solid var(--line); border-radius: 10px;273
padding: 0.65rem 0.8rem; margin: 0 0 0.55rem;274
}275
.cmain { flex: 1; min-width: 0; }276
.csubject { display: block; font-weight: 700; color: var(--ink); text-decoration: none; }277
.csubject:hover { color: var(--blue-deep); }278
.cby { margin: 0.12rem 0 0; color: var(--muted); font-size: var(--fs-sm); }279
.cby a { color: inherit; }280
.cacts { display: flex; align-items: center; gap: 0.3rem; flex: none; }281
.cacts code { font-family: var(--mono); color: var(--muted); font-size: 0.85rem; }282
a.status.markonly { padding: 0; background: transparent; min-height: 0; }283
.cchev::before {284
content: ""; width: 0.38rem; height: 0.38rem;285
border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;286
transform: translateY(-1px) rotate(45deg);287
}288
.cchev.open::before { transform: translateY(1px) rotate(225deg); }289
.cmsg {290
flex-basis: 100%; margin: 0.15rem 0 0; padding-top: 0.45rem;291
border-top: 1px solid var(--line); white-space: pre-wrap;292
}293
.cmsg[hidden] { display: none !important; }294
.clogmore { display: flex; gap: 0.6rem; margin: 0.4rem 0 0.6rem; }295
.clogmore a {296
display: inline-flex; align-items: center; min-height: var(--control-h);297
padding: 0 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);298
background: white; color: var(--ink); text-decoration: none;299
}300
@media (max-width: 800px) {301
.cacts { width: 100%; justify-content: flex-end; }302
}238
.avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; }303
.avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; }239
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; }304
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; }240
a.avatarlink { display: inline-grid; color: inherit; text-decoration: none; line-height: 0; }305
a.avatarlink { display: inline-grid; color: inherit; text-decoration: none; line-height: 0; }@@ -582,10 +582,60 @@
582
582
583
583
{{define "commits"}}
584
584
{{template "layout-start" .}}
585
<header class="pagehead"><h1>{{t "title.commits"}}</h1></header>
586
<ul class="clean">
587
{{range .Commits}}<li class="commitline">{{template "avatar" .}}<div><a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a> <div class="muted"><code>{{.Short}}</code> · {{template "commitwho" .}} · {{.Date}}</div></div></li>{{else}}<li class="muted">{{t "repo.noCommits"}}</li>{{end}}
588
</ul>
585
<form class="clog" method="get" action="/{{.Repo.FullPath}}/-/commits">
586
<div class="clogref">
587
<label class="clogpick">
588
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><circle cx="4" cy="3.2" r="1.5" fill="currentColor"/><circle cx="4" cy="12.8" r="1.5" fill="currentColor"/><circle cx="12" cy="6.4" r="1.5" fill="currentColor"/><path d="M4 4.7v6.6M4 6.4c2.4 0 4.2.2 6 .2 1.2 0 2 1 2 1.8" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>
589
<select name="rev" data-rev aria-label="{{t "tab.branches"}}">
590
{{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.Rev}} selected{{end}}>{{.Name}}</option>{{end}}
591
</select>
592
</label>
593
<a class="clogrepo" href="/{{.Repo.FullPath}}{{if .Rev}}?rev={{urlquery .Rev}}{{end}}">{{.Repo.Name}}</a>
594
</div>
595
<h1>{{t "title.commits"}}</h1>
596
<label class="clogsearch">
597
<input type="search" name="q" value="{{.Query}}" placeholder="{{t "commit.search"}}" aria-label="{{t "commit.search"}}" autocomplete="off">
598
<button type="submit" aria-label="{{t "commit.search"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0zm-.9 4.3 3.4 3.4a.75.75 0 1 0 1.1-1.1l-3.4-3.4a6 6 0 1 0-1.1 1.1z"/></svg></button>
599
</label>
600
</form>
601
{{if .CommitDays}}
602
{{range .CommitDays}}
603
<section class="cday">
604
<h2>{{.Label}}</h2>
605
{{range .Items}}
606
<article class="ccard" data-commit>
607
{{if .WhoURL}}<a class="avatarlink" href="{{.WhoURL}}">{{end}}
608
{{if .Ident}}{{.Ident}}{{else if .Avatar}}<img class="avatar" src="{{.Avatar}}" alt="">{{else}}<span class="avatar">{{if .Initial}}{{.Initial}}{{else}}{{initial .Author}}{{end}}</span>{{end}}
609
{{if .WhoURL}}</a>{{end}}
610
<div class="cmain">
611
<a class="csubject" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a>
612
<p class="cby">{{if .WhoURL}}<a href="{{.WhoURL}}">{{.Who}}</a>{{else}}{{.Who}}{{end}} {{t "commit.authoredWhen" .When}}</p>
613
</div>
614
<div class="cacts">
615
{{if .PipeStatus}}<a class="status {{.PipeStatus}} markonly" href="/{{$.Repo.FullPath}}/-/pipelines/{{.PipeID}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}
616
<code>{{if gt (len .SHA) 8}}{{slice .SHA 0 8}}{{else}}{{.SHA}}{{end}}</code>
617
<button type="button" class="iconbtn" data-copy="{{.SHA}}" aria-label="{{t "action.copy"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M5.5 1A1.5 1.5 0 0 0 4 2.5V10a1.5 1.5 0 0 0 1.5 1.5h6A1.5 1.5 0 0 0 13 10V2.5A1.5 1.5 0 0 0 11.5 1h-6zM2 5.5A1.5 1.5 0 0 1 3.5 4H4v6.5A2.5 2.5 0 0 0 6.5 13H11v.5A1.5 1.5 0 0 1 9.5 15h-6A1.5 1.5 0 0 1 2 13.5v-8z"/></svg></button>
618
<a class="iconbtn" href="/{{$.Repo.FullPath}}/-/tree?rev={{urlquery .SHA}}" aria-label="{{t "commit.files"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M1.5 3.25C1.5 2.56 2.06 2 2.75 2h3.19c.46 0 .9.18 1.23.51l.91.91h5.17c.69 0 1.25.56 1.25 1.25v7.08c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25V3.25z"/></svg></a>
619
<button type="button" class="iconbtn cchev" data-commit-toggle aria-expanded="false" aria-label="{{t "commit.expand"}}"></button>
620
</div>
621
<div class="cmsg" hidden>{{.Body}}</div>
622
</article>
623
{{end}}
624
</section>
625
{{end}}
626
{{if or .CommitPrev .CommitNext}}
627
<nav class="clogmore">
628
{{if .CommitPrev}}<a href="{{.CommitPrev}}">{{t "commit.prev"}}</a>{{end}}
629
{{if .CommitNext}}<a href="{{.CommitNext}}">{{t "commit.more"}}</a>{{end}}
630
</nav>
631
{{end}}
632
{{else if .Query}}
633
<p class="muted">{{t "commit.none"}}</p>
634
{{else}}
635
<p class="muted">{{t "repo.noCommits"}}</p>
636
{{end}}
637
<script src="/assets/commits.js"></script>
638
<script src="/assets/repo.js"></script>
589
639
{{template "layout-end" .}}
590
640
{{end}}
591
641
@@ -582,10 +582,60 @@582
582
583
{{define "commits"}}583
{{define "commits"}}584
{{template "layout-start" .}}584
{{template "layout-start" .}}585
<header class="pagehead"><h1>{{t "title.commits"}}</h1></header>585
<form class="clog" method="get" action="/{{.Repo.FullPath}}/-/commits">586
<ul class="clean">586
<div class="clogref">587
{{range .Commits}}<li class="commitline">{{template "avatar" .}}<div><a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a> <div class="muted"><code>{{.Short}}</code> · {{template "commitwho" .}} · {{.Date}}</div></div></li>{{else}}<li class="muted">{{t "repo.noCommits"}}</li>{{end}}587
<label class="clogpick">588
</ul>588
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><circle cx="4" cy="3.2" r="1.5" fill="currentColor"/><circle cx="4" cy="12.8" r="1.5" fill="currentColor"/><circle cx="12" cy="6.4" r="1.5" fill="currentColor"/><path d="M4 4.7v6.6M4 6.4c2.4 0 4.2.2 6 .2 1.2 0 2 1 2 1.8" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>589
<select name="rev" data-rev aria-label="{{t "tab.branches"}}">590
{{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.Rev}} selected{{end}}>{{.Name}}</option>{{end}}591
</select>592
</label>593
<a class="clogrepo" href="/{{.Repo.FullPath}}{{if .Rev}}?rev={{urlquery .Rev}}{{end}}">{{.Repo.Name}}</a>594
</div>595
<h1>{{t "title.commits"}}</h1>596
<label class="clogsearch">597
<input type="search" name="q" value="{{.Query}}" placeholder="{{t "commit.search"}}" aria-label="{{t "commit.search"}}" autocomplete="off">598
<button type="submit" aria-label="{{t "commit.search"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0zm-.9 4.3 3.4 3.4a.75.75 0 1 0 1.1-1.1l-3.4-3.4a6 6 0 1 0-1.1 1.1z"/></svg></button>599
</label>600
</form>601
{{if .CommitDays}}602
{{range .CommitDays}}603
<section class="cday">604
<h2>{{.Label}}</h2>605
{{range .Items}}606
<article class="ccard" data-commit>607
{{if .WhoURL}}<a class="avatarlink" href="{{.WhoURL}}">{{end}}608
{{if .Ident}}{{.Ident}}{{else if .Avatar}}<img class="avatar" src="{{.Avatar}}" alt="">{{else}}<span class="avatar">{{if .Initial}}{{.Initial}}{{else}}{{initial .Author}}{{end}}</span>{{end}}609
{{if .WhoURL}}</a>{{end}}610
<div class="cmain">611
<a class="csubject" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a>612
<p class="cby">{{if .WhoURL}}<a href="{{.WhoURL}}">{{.Who}}</a>{{else}}{{.Who}}{{end}} {{t "commit.authoredWhen" .When}}</p>613
</div>614
<div class="cacts">615
{{if .PipeStatus}}<a class="status {{.PipeStatus}} markonly" href="/{{$.Repo.FullPath}}/-/pipelines/{{.PipeID}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}616
<code>{{if gt (len .SHA) 8}}{{slice .SHA 0 8}}{{else}}{{.SHA}}{{end}}</code>617
<button type="button" class="iconbtn" data-copy="{{.SHA}}" aria-label="{{t "action.copy"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M5.5 1A1.5 1.5 0 0 0 4 2.5V10a1.5 1.5 0 0 0 1.5 1.5h6A1.5 1.5 0 0 0 13 10V2.5A1.5 1.5 0 0 0 11.5 1h-6zM2 5.5A1.5 1.5 0 0 1 3.5 4H4v6.5A2.5 2.5 0 0 0 6.5 13H11v.5A1.5 1.5 0 0 1 9.5 15h-6A1.5 1.5 0 0 1 2 13.5v-8z"/></svg></button>618
<a class="iconbtn" href="/{{$.Repo.FullPath}}/-/tree?rev={{urlquery .SHA}}" aria-label="{{t "commit.files"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M1.5 3.25C1.5 2.56 2.06 2 2.75 2h3.19c.46 0 .9.18 1.23.51l.91.91h5.17c.69 0 1.25.56 1.25 1.25v7.08c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25V3.25z"/></svg></a>619
<button type="button" class="iconbtn cchev" data-commit-toggle aria-expanded="false" aria-label="{{t "commit.expand"}}"></button>620
</div>621
<div class="cmsg" hidden>{{.Body}}</div>622
</article>623
{{end}}624
</section>625
{{end}}626
{{if or .CommitPrev .CommitNext}}627
<nav class="clogmore">628
{{if .CommitPrev}}<a href="{{.CommitPrev}}">{{t "commit.prev"}}</a>{{end}}629
{{if .CommitNext}}<a href="{{.CommitNext}}">{{t "commit.more"}}</a>{{end}}630
</nav>631
{{end}}632
{{else if .Query}}633
<p class="muted">{{t "commit.none"}}</p>634
{{else}}635
<p class="muted">{{t "repo.noCommits"}}</p>636
{{end}}637
<script src="/assets/commits.js"></script>638
<script src="/assets/repo.js"></script>589
{{template "layout-end" .}}639
{{template "layout-end" .}}590
{{end}}640
{{end}}591
641