BlueGit

timfa bluegit

Merge branch 'stage' into 'master'

timfa

Authored 2026-10-23 · 3 weeks ago

Hash
43e8e91a7738f7dafa1d5f746c8d0dea434f2174
Pipeline
Passed
58 files changed +4070 −435
docs/AUR.md +10 −5
@@ -4,10 +4,10 @@ Elke push naar `master` werkt `packaging/aur/PKGBUILD` bij en pusht die naar `ss
4 4
5 5 ## Package
6 6
7 Er is één source-package, `bluegit`. Geen `-bin`. De PKGBUILD haalt de GitLab-archieven op:
7 Er is één source-package, `bluegit`. Geen `-bin`. De PKGBUILD haalt het archief van BlueGit op, op de commit-sha:
8 8
9 9 ```text
10 https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
10 https://git.timfalken.com/timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
11 11 ```
12 12
13 13 Die map heet `bluegit-<commit>`. `pkgver` is `YYYYMMDDHHMMSS`, de UTC-committertijd van de commit. De CI-job neemt `CI_COMMIT_TIMESTAMP` (ISO 8601). Ontbreekt die, dan neemt `publish-aur.sh` `git show -s --format=%cI` en rekent die om naar UTC. Het lokale script en de self-updater gebruiken dezelfde committer-tijd, zodat dezelfde sha dezelfde `pkgver` houdt. `pkgrel` gaat terug naar 1. `_commit` is de volledige sha. Het CI-script vult `sha256sums` met de hash van dat archief. Het lokale script doet hetzelfde met `updpkgsums`. Beide maken `.SRCINFO` opnieuw met `makepkg --printsrcinfo`. Draait de CI-job als root, dan doet gebruiker `aurbuild` dat (`AUR_MAKEPKG_USER` overschrijft de naam). De gedeelde functies staan in `scripts/aur-common.sh`.
@@ -103,10 +103,15 @@ De mini-PC heeft `base-devel`, `go` en `pacman-contrib` niet als package-depende
103 103
104 104 ## Archief
105 105
106 Het archief is anoniem te downloaden:
106 Het archief van een commit is anoniem te downloaden zolang de repository publiek is. Een token is niet nodig. `tar.gz` en `zip` bestaan allebei. De map in het archief heet `bluegit-<commit>`, met de volledige sha.
107 107
108 108 ```text
109 https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
109 https://git.timfalken.com/timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
110 https://git.timfalken.com/timfa/bluegit/-/archive/<commit>/bluegit-<commit>.zip
110 111 ```
111 112
112 De publish-job haalt die tarball zonder token op en zet de sha256 in de PKGBUILD. `makepkg` gebruikt dezelfde URL.
113 Twee downloads van dezelfde sha geven dezelfde bytes. `git archive` zet de gzip-mtime op 0, dus de klok zit niet in de checksum. `sha256sums` in de PKGBUILD hoort bij die url. Een andere git-versie op de server kan het archiefformaat wijzigen; dan klopt een al gepubliceerde checksum niet meer.
114
115 Een branch- of tagarchief (`/-/branches/archive`, `/-/tags/archive`) volgt de punt van die ref. Die url hoort niet in de PKGBUILD: de bytes veranderen zodra de ref opschuift, en dan breekt `sha256sums`.
116
117 De publish-job haalt de tarball zonder token op en zet de sha256 in de PKGBUILD. `makepkg` gebruikt dezelfde URL.
@@ -4,10 +4,10 @@ Elke push naar `master` werkt `packaging/aur/PKGBUILD` bij en pusht die naar `ss
4
4
5## Package
5## Package
6
6
7Er is één source-package, `bluegit`. Geen `-bin`. De PKGBUILD haalt de GitLab-archieven op:
7Er is één source-package, `bluegit`. Geen `-bin`. De PKGBUILD haalt het archief van BlueGit op, op de commit-sha:
8
8
9```text
9```text
10https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
10https://git.timfalken.com/timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
11```
11```
12
12
13Die map heet `bluegit-<commit>`. `pkgver` is `YYYYMMDDHHMMSS`, de UTC-committertijd van de commit. De CI-job neemt `CI_COMMIT_TIMESTAMP` (ISO 8601). Ontbreekt die, dan neemt `publish-aur.sh` `git show -s --format=%cI` en rekent die om naar UTC. Het lokale script en de self-updater gebruiken dezelfde committer-tijd, zodat dezelfde sha dezelfde `pkgver` houdt. `pkgrel` gaat terug naar 1. `_commit` is de volledige sha. Het CI-script vult `sha256sums` met de hash van dat archief. Het lokale script doet hetzelfde met `updpkgsums`. Beide maken `.SRCINFO` opnieuw met `makepkg --printsrcinfo`. Draait de CI-job als root, dan doet gebruiker `aurbuild` dat (`AUR_MAKEPKG_USER` overschrijft de naam). De gedeelde functies staan in `scripts/aur-common.sh`.
13Die map heet `bluegit-<commit>`. `pkgver` is `YYYYMMDDHHMMSS`, de UTC-committertijd van de commit. De CI-job neemt `CI_COMMIT_TIMESTAMP` (ISO 8601). Ontbreekt die, dan neemt `publish-aur.sh` `git show -s --format=%cI` en rekent die om naar UTC. Het lokale script en de self-updater gebruiken dezelfde committer-tijd, zodat dezelfde sha dezelfde `pkgver` houdt. `pkgrel` gaat terug naar 1. `_commit` is de volledige sha. Het CI-script vult `sha256sums` met de hash van dat archief. Het lokale script doet hetzelfde met `updpkgsums`. Beide maken `.SRCINFO` opnieuw met `makepkg --printsrcinfo`. Draait de CI-job als root, dan doet gebruiker `aurbuild` dat (`AUR_MAKEPKG_USER` overschrijft de naam). De gedeelde functies staan in `scripts/aur-common.sh`.
@@ -103,10 +103,15 @@ De mini-PC heeft `base-devel`, `go` en `pacman-contrib` niet als package-depende
103
103
104## Archief
104## Archief
105
105
106Het archief is anoniem te downloaden:
106Het archief van een commit is anoniem te downloaden zolang de repository publiek is. Een token is niet nodig. `tar.gz` en `zip` bestaan allebei. De map in het archief heet `bluegit-<commit>`, met de volledige sha.
107
107
108```text
108```text
109https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
109https://git.timfalken.com/timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
110https://git.timfalken.com/timfa/bluegit/-/archive/<commit>/bluegit-<commit>.zip
110```
111```
111
112
112De publish-job haalt die tarball zonder token op en zet de sha256 in de PKGBUILD. `makepkg` gebruikt dezelfde URL.
113Twee downloads van dezelfde sha geven dezelfde bytes. `git archive` zet de gzip-mtime op 0, dus de klok zit niet in de checksum. `sha256sums` in de PKGBUILD hoort bij die url. Een andere git-versie op de server kan het archiefformaat wijzigen; dan klopt een al gepubliceerde checksum niet meer.
114
115Een branch- of tagarchief (`/-/branches/archive`, `/-/tags/archive`) volgt de punt van die ref. Die url hoort niet in de PKGBUILD: de bytes veranderen zodra de ref opschuift, en dan breekt `sha256sums`.
116
117De publish-job haalt de tarball zonder token op en zet de sha256 in de PKGBUILD. `makepkg` gebruikt dezelfde URL.
internal/gitrepo/repo.go +27 −3
@@ -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
@@ -529,17 +545,25 @@ func Archive(ctx context.Context, w io.Writer, gitBin, dir, prefix, name, format
529 545 if !HasTag(ctx, gitBin, dir, name) {
530 546 return i18n.E("err.tagMissing", name)
531 547 }
532 kind := format
548 return ArchiveAt(ctx, w, gitBin, dir, prefix, name, format)
549 }
550
551 // ArchiveAt schrijft een zip of tar.gz van een bestaande revisie.
552 // rev is een tagnaam of refs/heads/….
553 func ArchiveAt(ctx context.Context, w io.Writer, gitBin, dir, prefix, rev, format string) error {
533 554 if format != "zip" && format != "tar.gz" {
534 555 return i18n.E("err.notFound")
535 556 }
557 if rev == "" || strings.HasPrefix(rev, "-") || strings.Contains(rev, "..") || strings.ContainsAny(rev, " \t\r\n\\") {
558 return i18n.E("err.notFound")
559 }
536 560 if gitBin == "" {
537 561 gitBin = "git"
538 562 }
539 563 if prefix != "" && !strings.HasSuffix(prefix, "/") {
540 564 prefix += "/"
541 565 }
542 cmd := exec.CommandContext(ctx, gitBin, "-C", dir, "archive", "--format="+kind, "--prefix="+prefix, name)
566 cmd := exec.CommandContext(ctx, gitBin, "-C", dir, "archive", "--format="+format, "--prefix="+prefix, rev)
543 567 cmd.Stdout = w
544 568 var stderr bytes.Buffer
545 569 cmd.Stderr = &stderr
@@ -123,10 +123,26 @@ type Entry struct {
123
123
124// Log geeft de nieuwste commits.
124// Log geeft de nieuwste commits.
125func Log(ctx context.Context, gitBin, dir, rev string, limit int) ([]Commit, error) {
125func 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.
130func 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 = 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 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, nil
148 return nil, nil
@@ -529,17 +545,25 @@ func Archive(ctx context.Context, w io.Writer, gitBin, dir, prefix, name, format
529 if !HasTag(ctx, gitBin, dir, name) {
545 if !HasTag(ctx, gitBin, dir, name) {
530 return i18n.E("err.tagMissing", name)
546 return i18n.E("err.tagMissing", name)
531 }
547 }
532 kind := format
548 return ArchiveAt(ctx, w, gitBin, dir, prefix, name, format)
549}
550
551// ArchiveAt schrijft een zip of tar.gz van een bestaande revisie.
552// rev is een tagnaam of refs/heads/….
553func ArchiveAt(ctx context.Context, w io.Writer, gitBin, dir, prefix, rev, format string) error {
533 if format != "zip" && format != "tar.gz" {
554 if format != "zip" && format != "tar.gz" {
534 return i18n.E("err.notFound")
555 return i18n.E("err.notFound")
535 }
556 }
557 if rev == "" || strings.HasPrefix(rev, "-") || strings.Contains(rev, "..") || strings.ContainsAny(rev, " \t\r\n\\") {
558 return i18n.E("err.notFound")
559 }
536 if gitBin == "" {
560 if gitBin == "" {
537 gitBin = "git"
561 gitBin = "git"
538 }
562 }
539 if prefix != "" && !strings.HasSuffix(prefix, "/") {
563 if prefix != "" && !strings.HasSuffix(prefix, "/") {
540 prefix += "/"
564 prefix += "/"
541 }
565 }
542 cmd := exec.CommandContext(ctx, gitBin, "-C", dir, "archive", "--format="+kind, "--prefix="+prefix, name)
566 cmd := exec.CommandContext(ctx, gitBin, "-C", dir, "archive", "--format="+format, "--prefix="+prefix, rev)
543 cmd.Stdout = w
567 cmd.Stdout = w
544 var stderr bytes.Buffer
568 var stderr bytes.Buffer
545 cmd.Stderr = &stderr
569 cmd.Stderr = &stderr
internal/i18n/catalog.go +1 −1
@@ -145,7 +145,7 @@ var en = map[string]string{
145 145 "repo.binary": "Binary file.",
146 146 "repo.noTags": "No tags yet.",
147 147 "tag.search": "Find a tag",
148 "tag.create": "Create tag",
148 "tag.create": "New tag",
149 149 "tag.name": "Name",
150 150 "tag.target": "Branch or commit",
151 151 "tag.message": "Message",
@@ -145,7 +145,7 @@ var en = map[string]string{
145 "repo.binary": "Binary file.",
145 "repo.binary": "Binary file.",
146 "repo.noTags": "No tags yet.",
146 "repo.noTags": "No tags yet.",
147 "tag.search": "Find a tag",
147 "tag.search": "Find a tag",
148 "tag.create": "Create tag",
148 "tag.create": "New tag",
149 "tag.name": "Name",
149 "tag.name": "Name",
150 "tag.target": "Branch or commit",
150 "tag.target": "Branch or commit",
151 "tag.message": "Message",
151 "tag.message": "Message",
internal/i18n/catalog_branch.go +104 −0
@@ -25,6 +25,17 @@ var branchEN = map[string]string{
25 25 "branch.behind": "%d behind",
26 26 "branch.even": "Up to date",
27 27 "branch.actions": "Actions",
28 "branch.tab.overview": "Overview",
29 "branch.tab.active": "Active",
30 "branch.tab.stale": "Stale",
31 "branch.tab.all": "All",
32 "branch.group.active": "Active branches",
33 "branch.group.stale": "Stale branches",
34 "branch.filter": "Filter by branch name",
35 "branch.download": "Download",
36 "branch.makeMR": "Create MR",
37 "branch.none.active": "No active branches.",
38 "branch.none.stale": "No stale branches.",
28 39 "mr.draft": "Draft",
29 40 "mr.markDraft": "Mark as draft",
30 41 "mr.block.draft": "This merge request is a draft.",
@@ -51,6 +62,21 @@ var branchEN = map[string]string{
51 62 "mr.emptyCompare": "Choose two different branches",
52 63 "mr.commented": "commented",
53 64 "mr.pipeEvent": "Pipeline #%d is %s",
65 "mr.state.open": "Open",
66 "mr.state.merged": "Merged",
67 "mr.state.closed": "Closed",
68 "mr.when.created": "created %s",
69 "mr.when.merged": "merged %s",
70 "mr.when.closed": "closed %s",
71 "mr.wantsLead": "wants to merge",
72 "mr.wantsFrom": "from",
73 "mr.wantsInto": "into",
74 "mr.wantsTail": "-",
75 "mr.mergedByLead": "Merged by",
76 "mr.mergedByOn": "on",
77 "mr.mergedOn": "Merged on %s",
78 "mr.remove.short": "Delete source branch",
79 "mr.squash.short": "Squash",
54 80 "err.branchName": "Branch name %s is not allowed",
55 81 "err.branchLocked": "Branch %s cannot be renamed or deleted",
56 82 "err.branchConfirm": "Type the branch name to confirm.",
@@ -79,6 +105,17 @@ var branchNL = map[string]string{
79 105 "branch.behind": "%d achter",
80 106 "branch.even": "Bijgewerkt",
81 107 "branch.actions": "Acties",
108 "branch.tab.overview": "Overzicht",
109 "branch.tab.active": "Actief",
110 "branch.tab.stale": "Inactief",
111 "branch.tab.all": "Alles",
112 "branch.group.active": "Actieve branches",
113 "branch.group.stale": "Inactieve branches",
114 "branch.filter": "Filter op branchnaam",
115 "branch.download": "Downloaden",
116 "branch.makeMR": "MR maken",
117 "branch.none.active": "Geen actieve branches.",
118 "branch.none.stale": "Geen inactieve branches.",
82 119 "mr.draft": "Concept",
83 120 "mr.markDraft": "Als concept markeren",
84 121 "mr.block.draft": "Deze merge request is een concept.",
@@ -105,6 +142,21 @@ var branchNL = map[string]string{
105 142 "mr.emptyCompare": "Kies twee verschillende branches",
106 143 "mr.commented": "reageerde",
107 144 "mr.pipeEvent": "Pipeline #%d is %s",
145 "mr.state.open": "Open",
146 "mr.state.merged": "Gemerged",
147 "mr.state.closed": "Gesloten",
148 "mr.when.created": "aangemaakt %s",
149 "mr.when.merged": "gemerged %s",
150 "mr.when.closed": "gesloten %s",
151 "mr.wantsLead": "wil",
152 "mr.wantsFrom": "van",
153 "mr.wantsInto": "naar",
154 "mr.wantsTail": "mergen",
155 "mr.mergedByLead": "Gemerged door",
156 "mr.mergedByOn": "op",
157 "mr.mergedOn": "Gemerged op %s",
158 "mr.remove.short": "Bron verwijderen",
159 "mr.squash.short": "Squash",
108 160 "err.branchName": "Branchnaam %s is niet toegestaan",
109 161 "err.branchLocked": "Branch %s kan niet hernoemd of verwijderd worden",
110 162 "err.branchConfirm": "Typ de branchnaam ter bevestiging.",
@@ -133,6 +185,17 @@ var branchDE = map[string]string{
133 185 "branch.behind": "%d zurück",
134 186 "branch.even": "Aktuell",
135 187 "branch.actions": "Aktionen",
188 "branch.tab.overview": "Übersicht",
189 "branch.tab.active": "Aktiv",
190 "branch.tab.stale": "Veraltet",
191 "branch.tab.all": "Alle",
192 "branch.group.active": "Aktive Branches",
193 "branch.group.stale": "Veraltete Branches",
194 "branch.filter": "Nach Branchname filtern",
195 "branch.download": "Herunterladen",
196 "branch.makeMR": "MR erstellen",
197 "branch.none.active": "Keine aktiven Branches.",
198 "branch.none.stale": "Keine veralteten Branches.",
136 199 "mr.draft": "Entwurf",
137 200 "mr.markDraft": "Als Entwurf markieren",
138 201 "mr.block.draft": "Dieser Merge Request ist ein Entwurf.",
@@ -159,6 +222,21 @@ var branchDE = map[string]string{
159 222 "mr.emptyCompare": "Zwei verschiedene Branches wählen",
160 223 "mr.commented": "kommentierte",
161 224 "mr.pipeEvent": "Pipeline #%d ist %s",
225 "mr.state.open": "Offen",
226 "mr.state.merged": "Gemergt",
227 "mr.state.closed": "Geschlossen",
228 "mr.when.created": "erstellt %s",
229 "mr.when.merged": "gemergt %s",
230 "mr.when.closed": "geschlossen %s",
231 "mr.wantsLead": "möchte",
232 "mr.wantsFrom": "von",
233 "mr.wantsInto": "nach",
234 "mr.wantsTail": "mergen",
235 "mr.mergedByLead": "Gemergt von",
236 "mr.mergedByOn": "am",
237 "mr.mergedOn": "Gemergt am %s",
238 "mr.remove.short": "Quellbranch löschen",
239 "mr.squash.short": "Squash",
162 240 "err.branchName": "Branchname %s ist nicht erlaubt",
163 241 "err.branchLocked": "Branch %s kann nicht umbenannt oder gelöscht werden",
164 242 "err.branchConfirm": "Branchname zur Bestätigung eingeben.",
@@ -187,6 +265,17 @@ var branchFR = map[string]string{
187 265 "branch.behind": "%d en retard",
188 266 "branch.even": "À jour",
189 267 "branch.actions": "Actions",
268 "branch.tab.overview": "Aperçu",
269 "branch.tab.active": "Actives",
270 "branch.tab.stale": "Inactives",
271 "branch.tab.all": "Toutes",
272 "branch.group.active": "Branches actives",
273 "branch.group.stale": "Branches inactives",
274 "branch.filter": "Filtrer par nom de branche",
275 "branch.download": "Télécharger",
276 "branch.makeMR": "Créer une MR",
277 "branch.none.active": "Aucune branche active.",
278 "branch.none.stale": "Aucune branche inactive.",
190 279 "mr.draft": "Brouillon",
191 280 "mr.markDraft": "Marquer comme brouillon",
192 281 "mr.block.draft": "Cette merge request est un brouillon.",
@@ -213,6 +302,21 @@ var branchFR = map[string]string{
213 302 "mr.emptyCompare": "Choisissez deux branches différentes",
214 303 "mr.commented": "a commenté",
215 304 "mr.pipeEvent": "Le pipeline #%d est %s",
305 "mr.state.open": "Ouvert",
306 "mr.state.merged": "Fusionné",
307 "mr.state.closed": "Fermé",
308 "mr.when.created": "créée %s",
309 "mr.when.merged": "fusionnée %s",
310 "mr.when.closed": "fermée %s",
311 "mr.wantsLead": "veut fusionner",
312 "mr.wantsFrom": "de",
313 "mr.wantsInto": "vers",
314 "mr.wantsTail": "-",
315 "mr.mergedByLead": "Fusionné par",
316 "mr.mergedByOn": "le",
317 "mr.mergedOn": "Fusionné le %s",
318 "mr.remove.short": "Supprimer la source",
319 "mr.squash.short": "Squash",
216 320 "err.branchName": "Le nom de branche %s n'est pas permis",
217 321 "err.branchLocked": "La branche %s ne peut pas être renommée ou supprimée",
218 322 "err.branchConfirm": "Saisir le nom de la branche pour confirmer.",
@@ -25,6 +25,17 @@ var branchEN = map[string]string{
25 "branch.behind": "%d behind",
25 "branch.behind": "%d behind",
26 "branch.even": "Up to date",
26 "branch.even": "Up to date",
27 "branch.actions": "Actions",
27 "branch.actions": "Actions",
28 "branch.tab.overview": "Overview",
29 "branch.tab.active": "Active",
30 "branch.tab.stale": "Stale",
31 "branch.tab.all": "All",
32 "branch.group.active": "Active branches",
33 "branch.group.stale": "Stale branches",
34 "branch.filter": "Filter by branch name",
35 "branch.download": "Download",
36 "branch.makeMR": "Create MR",
37 "branch.none.active": "No active branches.",
38 "branch.none.stale": "No stale branches.",
28 "mr.draft": "Draft",
39 "mr.draft": "Draft",
29 "mr.markDraft": "Mark as draft",
40 "mr.markDraft": "Mark as draft",
30 "mr.block.draft": "This merge request is a draft.",
41 "mr.block.draft": "This merge request is a draft.",
@@ -51,6 +62,21 @@ var branchEN = map[string]string{
51 "mr.emptyCompare": "Choose two different branches",
62 "mr.emptyCompare": "Choose two different branches",
52 "mr.commented": "commented",
63 "mr.commented": "commented",
53 "mr.pipeEvent": "Pipeline #%d is %s",
64 "mr.pipeEvent": "Pipeline #%d is %s",
65 "mr.state.open": "Open",
66 "mr.state.merged": "Merged",
67 "mr.state.closed": "Closed",
68 "mr.when.created": "created %s",
69 "mr.when.merged": "merged %s",
70 "mr.when.closed": "closed %s",
71 "mr.wantsLead": "wants to merge",
72 "mr.wantsFrom": "from",
73 "mr.wantsInto": "into",
74 "mr.wantsTail": "-",
75 "mr.mergedByLead": "Merged by",
76 "mr.mergedByOn": "on",
77 "mr.mergedOn": "Merged on %s",
78 "mr.remove.short": "Delete source branch",
79 "mr.squash.short": "Squash",
54 "err.branchName": "Branch name %s is not allowed",
80 "err.branchName": "Branch name %s is not allowed",
55 "err.branchLocked": "Branch %s cannot be renamed or deleted",
81 "err.branchLocked": "Branch %s cannot be renamed or deleted",
56 "err.branchConfirm": "Type the branch name to confirm.",
82 "err.branchConfirm": "Type the branch name to confirm.",
@@ -79,6 +105,17 @@ var branchNL = map[string]string{
79 "branch.behind": "%d achter",
105 "branch.behind": "%d achter",
80 "branch.even": "Bijgewerkt",
106 "branch.even": "Bijgewerkt",
81 "branch.actions": "Acties",
107 "branch.actions": "Acties",
108 "branch.tab.overview": "Overzicht",
109 "branch.tab.active": "Actief",
110 "branch.tab.stale": "Inactief",
111 "branch.tab.all": "Alles",
112 "branch.group.active": "Actieve branches",
113 "branch.group.stale": "Inactieve branches",
114 "branch.filter": "Filter op branchnaam",
115 "branch.download": "Downloaden",
116 "branch.makeMR": "MR maken",
117 "branch.none.active": "Geen actieve branches.",
118 "branch.none.stale": "Geen inactieve branches.",
82 "mr.draft": "Concept",
119 "mr.draft": "Concept",
83 "mr.markDraft": "Als concept markeren",
120 "mr.markDraft": "Als concept markeren",
84 "mr.block.draft": "Deze merge request is een concept.",
121 "mr.block.draft": "Deze merge request is een concept.",
@@ -105,6 +142,21 @@ var branchNL = map[string]string{
105 "mr.emptyCompare": "Kies twee verschillende branches",
142 "mr.emptyCompare": "Kies twee verschillende branches",
106 "mr.commented": "reageerde",
143 "mr.commented": "reageerde",
107 "mr.pipeEvent": "Pipeline #%d is %s",
144 "mr.pipeEvent": "Pipeline #%d is %s",
145 "mr.state.open": "Open",
146 "mr.state.merged": "Gemerged",
147 "mr.state.closed": "Gesloten",
148 "mr.when.created": "aangemaakt %s",
149 "mr.when.merged": "gemerged %s",
150 "mr.when.closed": "gesloten %s",
151 "mr.wantsLead": "wil",
152 "mr.wantsFrom": "van",
153 "mr.wantsInto": "naar",
154 "mr.wantsTail": "mergen",
155 "mr.mergedByLead": "Gemerged door",
156 "mr.mergedByOn": "op",
157 "mr.mergedOn": "Gemerged op %s",
158 "mr.remove.short": "Bron verwijderen",
159 "mr.squash.short": "Squash",
108 "err.branchName": "Branchnaam %s is niet toegestaan",
160 "err.branchName": "Branchnaam %s is niet toegestaan",
109 "err.branchLocked": "Branch %s kan niet hernoemd of verwijderd worden",
161 "err.branchLocked": "Branch %s kan niet hernoemd of verwijderd worden",
110 "err.branchConfirm": "Typ de branchnaam ter bevestiging.",
162 "err.branchConfirm": "Typ de branchnaam ter bevestiging.",
@@ -133,6 +185,17 @@ var branchDE = map[string]string{
133 "branch.behind": "%d zurück",
185 "branch.behind": "%d zurück",
134 "branch.even": "Aktuell",
186 "branch.even": "Aktuell",
135 "branch.actions": "Aktionen",
187 "branch.actions": "Aktionen",
188 "branch.tab.overview": "Übersicht",
189 "branch.tab.active": "Aktiv",
190 "branch.tab.stale": "Veraltet",
191 "branch.tab.all": "Alle",
192 "branch.group.active": "Aktive Branches",
193 "branch.group.stale": "Veraltete Branches",
194 "branch.filter": "Nach Branchname filtern",
195 "branch.download": "Herunterladen",
196 "branch.makeMR": "MR erstellen",
197 "branch.none.active": "Keine aktiven Branches.",
198 "branch.none.stale": "Keine veralteten Branches.",
136 "mr.draft": "Entwurf",
199 "mr.draft": "Entwurf",
137 "mr.markDraft": "Als Entwurf markieren",
200 "mr.markDraft": "Als Entwurf markieren",
138 "mr.block.draft": "Dieser Merge Request ist ein Entwurf.",
201 "mr.block.draft": "Dieser Merge Request ist ein Entwurf.",
@@ -159,6 +222,21 @@ var branchDE = map[string]string{
159 "mr.emptyCompare": "Zwei verschiedene Branches wählen",
222 "mr.emptyCompare": "Zwei verschiedene Branches wählen",
160 "mr.commented": "kommentierte",
223 "mr.commented": "kommentierte",
161 "mr.pipeEvent": "Pipeline #%d ist %s",
224 "mr.pipeEvent": "Pipeline #%d ist %s",
225 "mr.state.open": "Offen",
226 "mr.state.merged": "Gemergt",
227 "mr.state.closed": "Geschlossen",
228 "mr.when.created": "erstellt %s",
229 "mr.when.merged": "gemergt %s",
230 "mr.when.closed": "geschlossen %s",
231 "mr.wantsLead": "möchte",
232 "mr.wantsFrom": "von",
233 "mr.wantsInto": "nach",
234 "mr.wantsTail": "mergen",
235 "mr.mergedByLead": "Gemergt von",
236 "mr.mergedByOn": "am",
237 "mr.mergedOn": "Gemergt am %s",
238 "mr.remove.short": "Quellbranch löschen",
239 "mr.squash.short": "Squash",
162 "err.branchName": "Branchname %s ist nicht erlaubt",
240 "err.branchName": "Branchname %s ist nicht erlaubt",
163 "err.branchLocked": "Branch %s kann nicht umbenannt oder gelöscht werden",
241 "err.branchLocked": "Branch %s kann nicht umbenannt oder gelöscht werden",
164 "err.branchConfirm": "Branchname zur Bestätigung eingeben.",
242 "err.branchConfirm": "Branchname zur Bestätigung eingeben.",
@@ -187,6 +265,17 @@ var branchFR = map[string]string{
187 "branch.behind": "%d en retard",
265 "branch.behind": "%d en retard",
188 "branch.even": "À jour",
266 "branch.even": "À jour",
189 "branch.actions": "Actions",
267 "branch.actions": "Actions",
268 "branch.tab.overview": "Aperçu",
269 "branch.tab.active": "Actives",
270 "branch.tab.stale": "Inactives",
271 "branch.tab.all": "Toutes",
272 "branch.group.active": "Branches actives",
273 "branch.group.stale": "Branches inactives",
274 "branch.filter": "Filtrer par nom de branche",
275 "branch.download": "Télécharger",
276 "branch.makeMR": "Créer une MR",
277 "branch.none.active": "Aucune branche active.",
278 "branch.none.stale": "Aucune branche inactive.",
190 "mr.draft": "Brouillon",
279 "mr.draft": "Brouillon",
191 "mr.markDraft": "Marquer comme brouillon",
280 "mr.markDraft": "Marquer comme brouillon",
192 "mr.block.draft": "Cette merge request est un brouillon.",
281 "mr.block.draft": "Cette merge request est un brouillon.",
@@ -213,6 +302,21 @@ var branchFR = map[string]string{
213 "mr.emptyCompare": "Choisissez deux branches différentes",
302 "mr.emptyCompare": "Choisissez deux branches différentes",
214 "mr.commented": "a commenté",
303 "mr.commented": "a commenté",
215 "mr.pipeEvent": "Le pipeline #%d est %s",
304 "mr.pipeEvent": "Le pipeline #%d est %s",
305 "mr.state.open": "Ouvert",
306 "mr.state.merged": "Fusionné",
307 "mr.state.closed": "Fermé",
308 "mr.when.created": "créée %s",
309 "mr.when.merged": "fusionnée %s",
310 "mr.when.closed": "fermée %s",
311 "mr.wantsLead": "veut fusionner",
312 "mr.wantsFrom": "de",
313 "mr.wantsInto": "vers",
314 "mr.wantsTail": "-",
315 "mr.mergedByLead": "Fusionné par",
316 "mr.mergedByOn": "le",
317 "mr.mergedOn": "Fusionné le %s",
318 "mr.remove.short": "Supprimer la source",
319 "mr.squash.short": "Squash",
216 "err.branchName": "Le nom de branche %s n'est pas permis",
320 "err.branchName": "Le nom de branche %s n'est pas permis",
217 "err.branchLocked": "La branche %s ne peut pas être renommée ou supprimée",
321 "err.branchLocked": "La branche %s ne peut pas être renommée ou supprimée",
218 "err.branchConfirm": "Saisir le nom de la branche pour confirmer.",
322 "err.branchConfirm": "Saisir le nom de la branche pour confirmer.",
internal/i18n/catalog_commit.go +100 −72
@@ -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
10var commitEN = map[string]string{
10var 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
31var commitNL = map[string]string{
38var 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
52var commitDE = map[string]string{
66var 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
73var commitFR = map[string]string{
94var 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}
internal/i18n/catalog_lang.go +3 −3
@@ -150,7 +150,7 @@ var nl = map[string]string{
150 150 "repo.binary": "Binair bestand.",
151 151 "repo.noTags": "Nog geen tags.",
152 152 "tag.search": "Zoek een tag",
153 "tag.create": "Tag aanmaken",
153 "tag.create": "Nieuwe tag",
154 154 "tag.name": "Naam",
155 155 "tag.target": "Branch of commit",
156 156 "tag.message": "Bericht",
@@ -772,7 +772,7 @@ var de = map[string]string{
772 772 "repo.binary": "Binäre Datei.",
773 773 "repo.noTags": "Noch keine Tags.",
774 774 "tag.search": "Tag suchen",
775 "tag.create": "Tag anlegen",
775 "tag.create": "Neuer Tag",
776 776 "tag.name": "Name",
777 777 "tag.target": "Branch oder Commit",
778 778 "tag.message": "Nachricht",
@@ -1394,7 +1394,7 @@ var fr = map[string]string{
1394 1394 "repo.binary": "Fichier binaire.",
1395 1395 "repo.noTags": "Pas encore de tags.",
1396 1396 "tag.search": "Chercher un tag",
1397 "tag.create": "Créer un tag",
1397 "tag.create": "Nouveau tag",
1398 1398 "tag.name": "Nom",
1399 1399 "tag.target": "Branche ou commit",
1400 1400 "tag.message": "Message",
@@ -150,7 +150,7 @@ var nl = map[string]string{
150 "repo.binary": "Binair bestand.",
150 "repo.binary": "Binair bestand.",
151 "repo.noTags": "Nog geen tags.",
151 "repo.noTags": "Nog geen tags.",
152 "tag.search": "Zoek een tag",
152 "tag.search": "Zoek een tag",
153 "tag.create": "Tag aanmaken",
153 "tag.create": "Nieuwe tag",
154 "tag.name": "Naam",
154 "tag.name": "Naam",
155 "tag.target": "Branch of commit",
155 "tag.target": "Branch of commit",
156 "tag.message": "Bericht",
156 "tag.message": "Bericht",
@@ -772,7 +772,7 @@ var de = map[string]string{
772 "repo.binary": "Binäre Datei.",
772 "repo.binary": "Binäre Datei.",
773 "repo.noTags": "Noch keine Tags.",
773 "repo.noTags": "Noch keine Tags.",
774 "tag.search": "Tag suchen",
774 "tag.search": "Tag suchen",
775 "tag.create": "Tag anlegen",
775 "tag.create": "Neuer Tag",
776 "tag.name": "Name",
776 "tag.name": "Name",
777 "tag.target": "Branch oder Commit",
777 "tag.target": "Branch oder Commit",
778 "tag.message": "Nachricht",
778 "tag.message": "Nachricht",
@@ -1394,7 +1394,7 @@ var fr = map[string]string{
1394 "repo.binary": "Fichier binaire.",
1394 "repo.binary": "Fichier binaire.",
1395 "repo.noTags": "Pas encore de tags.",
1395 "repo.noTags": "Pas encore de tags.",
1396 "tag.search": "Chercher un tag",
1396 "tag.search": "Chercher un tag",
1397 "tag.create": "Créer un tag",
1397 "tag.create": "Nouveau tag",
1398 "tag.name": "Nom",
1398 "tag.name": "Nom",
1399 "tag.target": "Branche ou commit",
1399 "tag.target": "Branche ou commit",
1400 "tag.message": "Message",
1400 "tag.message": "Message",
internal/i18n/catalog_list.go added +76 −0
@@ -0,0 +1,76 @@
1 package i18n
2
3 func init() {
4 addCatalog(en, listEN)
5 addCatalog(nl, listNL)
6 addCatalog(de, listDE)
7 addCatalog(fr, listFR)
8 }
9
10 var listEN = map[string]string{
11 "list.tabs": "Status",
12 "list.search": "Search or filter results...",
13 "list.sort": "Sort",
14 "list.sort.created": "Created date",
15 "list.sort.updated": "Updated date",
16 "list.sort.asc": "Oldest first",
17 "list.sort.desc": "Newest first",
18 "list.created": "created %s",
19 "list.by": "by",
20 "list.updated": "updated %s",
21 "list.merged": "Merged",
22 "list.newMR": "New merge request",
23 "list.comment": "%d comment",
24 "list.comments": "%d comments",
25 }
26
27 var listNL = map[string]string{
28 "list.tabs": "Status",
29 "list.search": "Zoek of filter resultaten...",
30 "list.sort": "Sorteren",
31 "list.sort.created": "Aanmaakdatum",
32 "list.sort.updated": "Bijgewerkt",
33 "list.sort.asc": "Oudste eerst",
34 "list.sort.desc": "Nieuwste eerst",
35 "list.created": "aangemaakt %s",
36 "list.by": "door",
37 "list.updated": "bijgewerkt %s",
38 "list.merged": "Gemerged",
39 "list.newMR": "Nieuwe merge request",
40 "list.comment": "%d reactie",
41 "list.comments": "%d reacties",
42 }
43
44 var listDE = map[string]string{
45 "list.tabs": "Status",
46 "list.search": "Suchen oder filtern...",
47 "list.sort": "Sortieren",
48 "list.sort.created": "Erstellungsdatum",
49 "list.sort.updated": "Aktualisiert",
50 "list.sort.asc": "Älteste zuerst",
51 "list.sort.desc": "Neueste zuerst",
52 "list.created": "erstellt %s",
53 "list.by": "von",
54 "list.updated": "aktualisiert %s",
55 "list.merged": "Zusammengeführt",
56 "list.newMR": "Neue Merge Request",
57 "list.comment": "%d Kommentar",
58 "list.comments": "%d Kommentare",
59 }
60
61 var listFR = map[string]string{
62 "list.tabs": "Statut",
63 "list.search": "Rechercher ou filtrer...",
64 "list.sort": "Trier",
65 "list.sort.created": "Date de création",
66 "list.sort.updated": "Mise à jour",
67 "list.sort.asc": "Plus anciennes d'abord",
68 "list.sort.desc": "Plus récentes d'abord",
69 "list.created": "créé %s",
70 "list.by": "par",
71 "list.updated": "mise à jour %s",
72 "list.merged": "Fusionnée",
73 "list.newMR": "Nouvelle merge request",
74 "list.comment": "%d commentaire",
75 "list.comments": "%d commentaires",
76 }
@@ -0,0 +1,76 @@
1package i18n
2
3func init() {
4 addCatalog(en, listEN)
5 addCatalog(nl, listNL)
6 addCatalog(de, listDE)
7 addCatalog(fr, listFR)
8}
9
10var listEN = map[string]string{
11 "list.tabs": "Status",
12 "list.search": "Search or filter results...",
13 "list.sort": "Sort",
14 "list.sort.created": "Created date",
15 "list.sort.updated": "Updated date",
16 "list.sort.asc": "Oldest first",
17 "list.sort.desc": "Newest first",
18 "list.created": "created %s",
19 "list.by": "by",
20 "list.updated": "updated %s",
21 "list.merged": "Merged",
22 "list.newMR": "New merge request",
23 "list.comment": "%d comment",
24 "list.comments": "%d comments",
25}
26
27var listNL = map[string]string{
28 "list.tabs": "Status",
29 "list.search": "Zoek of filter resultaten...",
30 "list.sort": "Sorteren",
31 "list.sort.created": "Aanmaakdatum",
32 "list.sort.updated": "Bijgewerkt",
33 "list.sort.asc": "Oudste eerst",
34 "list.sort.desc": "Nieuwste eerst",
35 "list.created": "aangemaakt %s",
36 "list.by": "door",
37 "list.updated": "bijgewerkt %s",
38 "list.merged": "Gemerged",
39 "list.newMR": "Nieuwe merge request",
40 "list.comment": "%d reactie",
41 "list.comments": "%d reacties",
42}
43
44var listDE = map[string]string{
45 "list.tabs": "Status",
46 "list.search": "Suchen oder filtern...",
47 "list.sort": "Sortieren",
48 "list.sort.created": "Erstellungsdatum",
49 "list.sort.updated": "Aktualisiert",
50 "list.sort.asc": "Älteste zuerst",
51 "list.sort.desc": "Neueste zuerst",
52 "list.created": "erstellt %s",
53 "list.by": "von",
54 "list.updated": "aktualisiert %s",
55 "list.merged": "Zusammengeführt",
56 "list.newMR": "Neue Merge Request",
57 "list.comment": "%d Kommentar",
58 "list.comments": "%d Kommentare",
59}
60
61var listFR = map[string]string{
62 "list.tabs": "Statut",
63 "list.search": "Rechercher ou filtrer...",
64 "list.sort": "Trier",
65 "list.sort.created": "Date de création",
66 "list.sort.updated": "Mise à jour",
67 "list.sort.asc": "Plus anciennes d'abord",
68 "list.sort.desc": "Plus récentes d'abord",
69 "list.created": "créé %s",
70 "list.by": "par",
71 "list.updated": "mise à jour %s",
72 "list.merged": "Fusionnée",
73 "list.newMR": "Nouvelle merge request",
74 "list.comment": "%d commentaire",
75 "list.comments": "%d commentaires",
76}
internal/i18n/catalog_pipe.go added +44 −0
@@ -0,0 +1,44 @@
1 package i18n
2
3 func init() {
4 addCatalog(en, pipeEN)
5 addCatalog(nl, pipeNL)
6 addCatalog(de, pipeDE)
7 addCatalog(fr, pipeFR)
8 }
9
10 var pipeEN = map[string]string{
11 "pipe.retry": "Retry",
12 "pipe.retry.all": "Retry entire pipeline",
13 "pipe.retry.failed": "Retry failed jobs",
14 "flash.pipeRetry": "Pipeline retried",
15 "err.pipeNoFailed": "this pipeline has no failed jobs",
16 "err.pipeRetryMode": "mode must be all or failed",
17 }
18
19 var pipeNL = map[string]string{
20 "pipe.retry": "Opnieuw",
21 "pipe.retry.all": "Hele pipeline opnieuw",
22 "pipe.retry.failed": "Alleen mislukte jobs",
23 "flash.pipeRetry": "Pipeline opnieuw gestart",
24 "err.pipeNoFailed": "deze pipeline heeft geen mislukte jobs",
25 "err.pipeRetryMode": "mode moet all of failed zijn",
26 }
27
28 var pipeDE = map[string]string{
29 "pipe.retry": "Erneut",
30 "pipe.retry.all": "Gesamte Pipeline erneut",
31 "pipe.retry.failed": "Nur fehlgeschlagene Jobs",
32 "flash.pipeRetry": "Pipeline erneut gestartet",
33 "err.pipeNoFailed": "diese Pipeline hat keine fehlgeschlagenen Jobs",
34 "err.pipeRetryMode": "Modus muss all oder failed sein",
35 }
36
37 var pipeFR = map[string]string{
38 "pipe.retry": "Relancer",
39 "pipe.retry.all": "Relancer tout le pipeline",
40 "pipe.retry.failed": "Relancer les jobs en échec",
41 "flash.pipeRetry": "Pipeline relancé",
42 "err.pipeNoFailed": "ce pipeline n'a aucun job en échec",
43 "err.pipeRetryMode": "le mode doit être all ou failed",
44 }
@@ -0,0 +1,44 @@
1package i18n
2
3func init() {
4 addCatalog(en, pipeEN)
5 addCatalog(nl, pipeNL)
6 addCatalog(de, pipeDE)
7 addCatalog(fr, pipeFR)
8}
9
10var pipeEN = map[string]string{
11 "pipe.retry": "Retry",
12 "pipe.retry.all": "Retry entire pipeline",
13 "pipe.retry.failed": "Retry failed jobs",
14 "flash.pipeRetry": "Pipeline retried",
15 "err.pipeNoFailed": "this pipeline has no failed jobs",
16 "err.pipeRetryMode": "mode must be all or failed",
17}
18
19var pipeNL = map[string]string{
20 "pipe.retry": "Opnieuw",
21 "pipe.retry.all": "Hele pipeline opnieuw",
22 "pipe.retry.failed": "Alleen mislukte jobs",
23 "flash.pipeRetry": "Pipeline opnieuw gestart",
24 "err.pipeNoFailed": "deze pipeline heeft geen mislukte jobs",
25 "err.pipeRetryMode": "mode moet all of failed zijn",
26}
27
28var pipeDE = map[string]string{
29 "pipe.retry": "Erneut",
30 "pipe.retry.all": "Gesamte Pipeline erneut",
31 "pipe.retry.failed": "Nur fehlgeschlagene Jobs",
32 "flash.pipeRetry": "Pipeline erneut gestartet",
33 "err.pipeNoFailed": "diese Pipeline hat keine fehlgeschlagenen Jobs",
34 "err.pipeRetryMode": "Modus muss all oder failed sein",
35}
36
37var pipeFR = map[string]string{
38 "pipe.retry": "Relancer",
39 "pipe.retry.all": "Relancer tout le pipeline",
40 "pipe.retry.failed": "Relancer les jobs en échec",
41 "flash.pipeRetry": "Pipeline relancé",
42 "err.pipeNoFailed": "ce pipeline n'a aucun job en échec",
43 "err.pipeRetryMode": "le mode doit être all ou failed",
44}
internal/server/api_flow.go +33 −0
@@ -394,6 +394,39 @@ func (s *Server) apiPipeline(w http.ResponseWriter, r *http.Request) {
394 394 writeJSON(w, http.StatusOK, s.pipeJSON(repo, p))
395 395 }
396 396
397 func (s *Server) apiRetryPipeline(w http.ResponseWriter, r *http.Request) {
398 repo, _, ok := s.apiRepo(w, r, access.RoleDeveloper)
399 if !ok {
400 return
401 }
402 pipeID, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
403 if err != nil {
404 s.writeAPIErr(w, r, fail(404, i18n.E("err.notFound")))
405 return
406 }
407 var body struct {
408 Mode string `json:"mode"`
409 }
410 if err := readJSON(r, &body); err != nil {
411 s.writeAPIErr(w, r, fail(400, i18n.E("err.json")))
412 return
413 }
414 id, err := s.opRetryPipeline(r.Context(), apiUser(r), repo, pipeID, body.Mode)
415 if !s.apiOK(w, r, err) {
416 return
417 }
418 p, err := s.Store.PipelineByID(r.Context(), repo.ID, id)
419 if err != nil {
420 s.writeAPIErr(w, r, notFound(err))
421 return
422 }
423 code := http.StatusOK
424 if body.Mode == "all" {
425 code = http.StatusCreated
426 }
427 writeJSON(w, code, s.pipeJSON(repo, p))
428 }
429
397 430 func (s *Server) apiCancelPipeline(w http.ResponseWriter, r *http.Request) {
398 431 repo, _, ok := s.apiRepo(w, r, access.RoleDeveloper)
399 432 if !ok {
@@ -394,6 +394,39 @@ func (s *Server) apiPipeline(w http.ResponseWriter, r *http.Request) {
394 writeJSON(w, http.StatusOK, s.pipeJSON(repo, p))
394 writeJSON(w, http.StatusOK, s.pipeJSON(repo, p))
395}
395}
396
396
397func (s *Server) apiRetryPipeline(w http.ResponseWriter, r *http.Request) {
398 repo, _, ok := s.apiRepo(w, r, access.RoleDeveloper)
399 if !ok {
400 return
401 }
402 pipeID, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
403 if err != nil {
404 s.writeAPIErr(w, r, fail(404, i18n.E("err.notFound")))
405 return
406 }
407 var body struct {
408 Mode string `json:"mode"`
409 }
410 if err := readJSON(r, &body); err != nil {
411 s.writeAPIErr(w, r, fail(400, i18n.E("err.json")))
412 return
413 }
414 id, err := s.opRetryPipeline(r.Context(), apiUser(r), repo, pipeID, body.Mode)
415 if !s.apiOK(w, r, err) {
416 return
417 }
418 p, err := s.Store.PipelineByID(r.Context(), repo.ID, id)
419 if err != nil {
420 s.writeAPIErr(w, r, notFound(err))
421 return
422 }
423 code := http.StatusOK
424 if body.Mode == "all" {
425 code = http.StatusCreated
426 }
427 writeJSON(w, code, s.pipeJSON(repo, p))
428}
429
397func (s *Server) apiCancelPipeline(w http.ResponseWriter, r *http.Request) {
430func (s *Server) apiCancelPipeline(w http.ResponseWriter, r *http.Request) {
398 repo, _, ok := s.apiRepo(w, r, access.RoleDeveloper)
431 repo, _, ok := s.apiRepo(w, r, access.RoleDeveloper)
399 if !ok {
432 if !ok {
internal/server/api_http.go +21 −4
@@ -29,6 +29,7 @@ const (
29 29 authUser apiAuth = iota
30 30 authPublic
31 31 authRelease
32 authOptional
32 33 )
33 34
34 35 type apiHandler func(*Server, http.ResponseWriter, *http.Request)
@@ -94,6 +95,10 @@ func (s *Server) serveAPI(w http.ResponseWriter, r *http.Request, rt apiRoute) {
94 95 actor, ok := r.Context().Value(actorKey{}).(apiActor)
95 96 if !ok {
96 97 tok := tokenFrom(r)
98 if tok == "" && rt.Auth == authOptional {
99 rt.Handler(s, w, r)
100 return
101 }
97 102 if tok == "" || !strings.HasPrefix(tok, "bg_") {
98 103 s.writeAPIErr(w, r, fail(http.StatusUnauthorized, i18n.E("err.apiAuth")))
99 104 return
@@ -254,7 +259,17 @@ func openAPIDoc() map[string]any {
254 259 "summary": rt.Summary,
255 260 "responses": map[string]any{"200": map[string]any{"description": "OK"}, "default": map[string]any{"description": "Error", "content": map[string]any{"application/json": map[string]any{"schema": map[string]any{"$ref": "#/components/schemas/Error"}}}}},
256 261 }
257 if rt.Auth != authPublic {
262 switch rt.Auth {
263 case authPublic:
264 case authOptional:
265 op["description"] = "Public. Without a token the viewer is anonymous and only sees public repositories and groups. A valid token includes private items that account may see. Contributions follow the same filter."
266 op["security"] = []any{
267 map[string]any{},
268 map[string]any{"bearer": []any{}},
269 map[string]any{"privateToken": []any{}},
270 map[string]any{"basic": []any{}},
271 }
272 default:
258 273 op["security"] = []any{
259 274 map[string]any{"bearer": []any{}},
260 275 map[string]any{"privateToken": []any{}},
@@ -322,11 +337,13 @@ func apiIndex() []byte {
322 337 routes := []row{{Method: http.MethodGet, Path: "/api/v1/openapi.json", Summary: "OpenAPI document", Auth: "public"}}
323 338 for _, rt := range apiCatalog {
324 339 auth := "token"
325 if rt.Auth == authPublic {
340 switch rt.Auth {
341 case authPublic:
326 342 auth = "public"
327 }
328 if rt.Auth == authRelease {
343 case authRelease:
329 344 auth = "token_or_job"
345 case authOptional:
346 auth = "public_or_token"
330 347 }
331 348 routes = append(routes, row{Method: rt.Method, Path: rt.Path, Summary: rt.Summary, Auth: auth})
332 349 }
@@ -29,6 +29,7 @@ const (
29 authUser apiAuth = iota
29 authUser apiAuth = iota
30 authPublic
30 authPublic
31 authRelease
31 authRelease
32 authOptional
32)
33)
33
34
34type apiHandler func(*Server, http.ResponseWriter, *http.Request)
35type apiHandler func(*Server, http.ResponseWriter, *http.Request)
@@ -94,6 +95,10 @@ func (s *Server) serveAPI(w http.ResponseWriter, r *http.Request, rt apiRoute) {
94 actor, ok := r.Context().Value(actorKey{}).(apiActor)
95 actor, ok := r.Context().Value(actorKey{}).(apiActor)
95 if !ok {
96 if !ok {
96 tok := tokenFrom(r)
97 tok := tokenFrom(r)
98 if tok == "" && rt.Auth == authOptional {
99 rt.Handler(s, w, r)
100 return
101 }
97 if tok == "" || !strings.HasPrefix(tok, "bg_") {
102 if tok == "" || !strings.HasPrefix(tok, "bg_") {
98 s.writeAPIErr(w, r, fail(http.StatusUnauthorized, i18n.E("err.apiAuth")))
103 s.writeAPIErr(w, r, fail(http.StatusUnauthorized, i18n.E("err.apiAuth")))
99 return
104 return
@@ -254,7 +259,17 @@ func openAPIDoc() map[string]any {
254 "summary": rt.Summary,
259 "summary": rt.Summary,
255 "responses": map[string]any{"200": map[string]any{"description": "OK"}, "default": map[string]any{"description": "Error", "content": map[string]any{"application/json": map[string]any{"schema": map[string]any{"$ref": "#/components/schemas/Error"}}}}},
260 "responses": map[string]any{"200": map[string]any{"description": "OK"}, "default": map[string]any{"description": "Error", "content": map[string]any{"application/json": map[string]any{"schema": map[string]any{"$ref": "#/components/schemas/Error"}}}}},
256 }
261 }
257 if rt.Auth != authPublic {
262 switch rt.Auth {
263 case authPublic:
264 case authOptional:
265 op["description"] = "Public. Without a token the viewer is anonymous and only sees public repositories and groups. A valid token includes private items that account may see. Contributions follow the same filter."
266 op["security"] = []any{
267 map[string]any{},
268 map[string]any{"bearer": []any{}},
269 map[string]any{"privateToken": []any{}},
270 map[string]any{"basic": []any{}},
271 }
272 default:
258 op["security"] = []any{
273 op["security"] = []any{
259 map[string]any{"bearer": []any{}},
274 map[string]any{"bearer": []any{}},
260 map[string]any{"privateToken": []any{}},
275 map[string]any{"privateToken": []any{}},
@@ -322,11 +337,13 @@ func apiIndex() []byte {
322 routes := []row{{Method: http.MethodGet, Path: "/api/v1/openapi.json", Summary: "OpenAPI document", Auth: "public"}}
337 routes := []row{{Method: http.MethodGet, Path: "/api/v1/openapi.json", Summary: "OpenAPI document", Auth: "public"}}
323 for _, rt := range apiCatalog {
338 for _, rt := range apiCatalog {
324 auth := "token"
339 auth := "token"
325 if rt.Auth == authPublic {
340 switch rt.Auth {
341 case authPublic:
326 auth = "public"
342 auth = "public"
327 }
343 case authRelease:
328 if rt.Auth == authRelease {
329 auth = "token_or_job"
344 auth = "token_or_job"
345 case authOptional:
346 auth = "public_or_token"
330 }
347 }
331 routes = append(routes, row{Method: rt.Method, Path: rt.Path, Summary: rt.Summary, Auth: auth})
348 routes = append(routes, row{Method: rt.Method, Path: rt.Path, Summary: rt.Summary, Auth: auth})
332 }
349 }
internal/server/api_openapi.go +17 −1
@@ -37,6 +37,14 @@ func decorateAPI(paths map[string]map[string]any, schemas map[string]any) {
37 37 "content": jsonSchema(schema),
38 38 }
39 39 }
40 if op := apiOp(paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "POST"); op != nil {
41 responses, _ := op["responses"].(map[string]any)
42 if responses != nil {
43 if okResp, ok := responses["200"]; ok {
44 responses["201"] = okResp
45 }
46 }
47 }
40 48 if op := apiOp(paths, "/repos/{owner}/{repo}/issues/{number}/notes", "POST"); op != nil {
41 49 responses, _ := op["responses"].(map[string]any)
42 50 if responses == nil {
@@ -107,6 +115,7 @@ func apiBinds() []apiBind {
107 115 {path: pipes, method: "POST", code: "201", body: "PipelineCreate", resp: "Pipeline"},
108 116 {path: pipe, method: "GET", code: "200", resp: "Pipeline"},
109 117 {path: pipe + "/cancel", method: "POST", code: "200", resp: "Pipeline"},
118 {path: pipe + "/retry", method: "POST", code: "200", body: "PipelineRetry", resp: "Pipeline"},
110 119 {path: pipe + "/jobs", method: "GET", code: "200", resp: "Job", array: true},
111 120 {path: job, method: "GET", code: "200", resp: "Job"},
112 121 {path: job + "/play", method: "POST", code: "200", resp: "Job"},
@@ -233,6 +242,13 @@ func apiSchemas() map[string]any {
233 242 "PipelineCreate": obj("Start a pipeline.", map[string]any{
234 243 "ref": str("Branch, tag or full ref to run."),
235 244 }),
245 "PipelineRetry": obj("Retry a pipeline. all starts a new pipeline on the same commit, ref, source and merge request. failed requeues failed jobs and the skipped or never-started jobs that depend on them. The response is 201 for all and 200 for failed.", map[string]any{
246 "mode": map[string]any{
247 "type": "string",
248 "description": "all or failed.",
249 "enum": []any{"all", "failed"},
250 },
251 }),
236 252 "Job": obj("CI job.", map[string]any{
237 253 "id": integer("Job id."),
238 254 "name": str("Job name."),
@@ -271,7 +287,7 @@ func apiSchemas() map[string]any {
271 287 "branch_filter": str("Branch filter. Empty matches every branch."),
272 288 "active": boolean("Hook is enabled."),
273 289 }),
274 "User": obj("User. counts, repos and groups are present on GET /users/{username}. instance_admin and language are present for the signed-in user.", map[string]any{
290 "User": obj("User. counts, repos and groups are present on GET /users/{username}, which is public. Without a token only public repositories and groups are included, and contributions count only those repositories. instance_admin and language are present for the signed-in user.", map[string]any{
275 291 "id": integer("User id."),
276 292 "username": str("Username."),
277 293 "name": str("Display name. Empty when unset."),
@@ -37,6 +37,14 @@ func decorateAPI(paths map[string]map[string]any, schemas map[string]any) {
37 "content": jsonSchema(schema),
37 "content": jsonSchema(schema),
38 }
38 }
39 }
39 }
40 if op := apiOp(paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "POST"); op != nil {
41 responses, _ := op["responses"].(map[string]any)
42 if responses != nil {
43 if okResp, ok := responses["200"]; ok {
44 responses["201"] = okResp
45 }
46 }
47 }
40 if op := apiOp(paths, "/repos/{owner}/{repo}/issues/{number}/notes", "POST"); op != nil {
48 if op := apiOp(paths, "/repos/{owner}/{repo}/issues/{number}/notes", "POST"); op != nil {
41 responses, _ := op["responses"].(map[string]any)
49 responses, _ := op["responses"].(map[string]any)
42 if responses == nil {
50 if responses == nil {
@@ -107,6 +115,7 @@ func apiBinds() []apiBind {
107 {path: pipes, method: "POST", code: "201", body: "PipelineCreate", resp: "Pipeline"},
115 {path: pipes, method: "POST", code: "201", body: "PipelineCreate", resp: "Pipeline"},
108 {path: pipe, method: "GET", code: "200", resp: "Pipeline"},
116 {path: pipe, method: "GET", code: "200", resp: "Pipeline"},
109 {path: pipe + "/cancel", method: "POST", code: "200", resp: "Pipeline"},
117 {path: pipe + "/cancel", method: "POST", code: "200", resp: "Pipeline"},
118 {path: pipe + "/retry", method: "POST", code: "200", body: "PipelineRetry", resp: "Pipeline"},
110 {path: pipe + "/jobs", method: "GET", code: "200", resp: "Job", array: true},
119 {path: pipe + "/jobs", method: "GET", code: "200", resp: "Job", array: true},
111 {path: job, method: "GET", code: "200", resp: "Job"},
120 {path: job, method: "GET", code: "200", resp: "Job"},
112 {path: job + "/play", method: "POST", code: "200", resp: "Job"},
121 {path: job + "/play", method: "POST", code: "200", resp: "Job"},
@@ -233,6 +242,13 @@ func apiSchemas() map[string]any {
233 "PipelineCreate": obj("Start a pipeline.", map[string]any{
242 "PipelineCreate": obj("Start a pipeline.", map[string]any{
234 "ref": str("Branch, tag or full ref to run."),
243 "ref": str("Branch, tag or full ref to run."),
235 }),
244 }),
245 "PipelineRetry": obj("Retry a pipeline. all starts a new pipeline on the same commit, ref, source and merge request. failed requeues failed jobs and the skipped or never-started jobs that depend on them. The response is 201 for all and 200 for failed.", map[string]any{
246 "mode": map[string]any{
247 "type": "string",
248 "description": "all or failed.",
249 "enum": []any{"all", "failed"},
250 },
251 }),
236 "Job": obj("CI job.", map[string]any{
252 "Job": obj("CI job.", map[string]any{
237 "id": integer("Job id."),
253 "id": integer("Job id."),
238 "name": str("Job name."),
254 "name": str("Job name."),
@@ -271,7 +287,7 @@ func apiSchemas() map[string]any {
271 "branch_filter": str("Branch filter. Empty matches every branch."),
287 "branch_filter": str("Branch filter. Empty matches every branch."),
272 "active": boolean("Hook is enabled."),
288 "active": boolean("Hook is enabled."),
273 }),
289 }),
274 "User": obj("User. counts, repos and groups are present on GET /users/{username}. instance_admin and language are present for the signed-in user.", map[string]any{
290 "User": obj("User. counts, repos and groups are present on GET /users/{username}, which is public. Without a token only public repositories and groups are included, and contributions count only those repositories. instance_admin and language are present for the signed-in user.", map[string]any{
275 "id": integer("User id."),
291 "id": integer("User id."),
276 "username": str("Username."),
292 "username": str("Username."),
277 "name": str("Display name. Empty when unset."),
293 "name": str("Display name. Empty when unset."),
internal/server/api_openapi_test.go +15 −0
@@ -49,6 +49,9 @@ func TestOpenAPISchemas(t *testing.T) {
49 49
50 50 assertBody(t, paths, "/projects/{owner}/{repo}/pipelines", "post", "PipelineCreate")
51 51 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines", "post", "201", "#/components/schemas/Pipeline")
52 assertBody(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "post", "PipelineRetry")
53 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "post", "200", "#/components/schemas/Pipeline")
54 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "post", "201", "#/components/schemas/Pipeline")
52 55 assertItems(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/jobs", "get", "200", "#/components/schemas/Job")
53 56 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}", "get", "200", "#/components/schemas/Job")
54 57
@@ -71,6 +74,18 @@ func TestOpenAPISchemas(t *testing.T) {
71 74 assertBody(t, paths, "/user", "put", "UserUpdate")
72 75 assertResp(t, paths, "/user", "get", "200", "#/components/schemas/User")
73 76 assertResp(t, paths, "/users/{username}", "get", "200", "#/components/schemas/User")
77 op := paths["/users/{username}"].(map[string]any)["get"].(map[string]any)
78 sec, _ := op["security"].([]any)
79 optional := false
80 for _, item := range sec {
81 req, _ := item.(map[string]any)
82 if len(req) == 0 {
83 optional = true
84 }
85 }
86 if !optional {
87 t.Fatal("GET /users/{username} moet zonder token mogen")
88 }
74 89 }
75 90
76 91 func TestResourceWebURL(t *testing.T) {
@@ -49,6 +49,9 @@ func TestOpenAPISchemas(t *testing.T) {
49
49
50 assertBody(t, paths, "/projects/{owner}/{repo}/pipelines", "post", "PipelineCreate")
50 assertBody(t, paths, "/projects/{owner}/{repo}/pipelines", "post", "PipelineCreate")
51 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines", "post", "201", "#/components/schemas/Pipeline")
51 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines", "post", "201", "#/components/schemas/Pipeline")
52 assertBody(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "post", "PipelineRetry")
53 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "post", "200", "#/components/schemas/Pipeline")
54 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/retry", "post", "201", "#/components/schemas/Pipeline")
52 assertItems(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/jobs", "get", "200", "#/components/schemas/Job")
55 assertItems(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/jobs", "get", "200", "#/components/schemas/Job")
53 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}", "get", "200", "#/components/schemas/Job")
56 assertResp(t, paths, "/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}", "get", "200", "#/components/schemas/Job")
54
57
@@ -71,6 +74,18 @@ func TestOpenAPISchemas(t *testing.T) {
71 assertBody(t, paths, "/user", "put", "UserUpdate")
74 assertBody(t, paths, "/user", "put", "UserUpdate")
72 assertResp(t, paths, "/user", "get", "200", "#/components/schemas/User")
75 assertResp(t, paths, "/user", "get", "200", "#/components/schemas/User")
73 assertResp(t, paths, "/users/{username}", "get", "200", "#/components/schemas/User")
76 assertResp(t, paths, "/users/{username}", "get", "200", "#/components/schemas/User")
77 op := paths["/users/{username}"].(map[string]any)["get"].(map[string]any)
78 sec, _ := op["security"].([]any)
79 optional := false
80 for _, item := range sec {
81 req, _ := item.(map[string]any)
82 if len(req) == 0 {
83 optional = true
84 }
85 }
86 if !optional {
87 t.Fatal("GET /users/{username} moet zonder token mogen")
88 }
74}
89}
75
90
76func TestResourceWebURL(t *testing.T) {
91func TestResourceWebURL(t *testing.T) {
internal/server/api_routes.go +2 −1
@@ -13,7 +13,7 @@ var apiCatalog = []apiRoute{
13 13 {http.MethodGet, "/api/v1/user", access.ScopeRead, authUser, "Current user", (*Server).apiGetUser},
14 14 {http.MethodPut, "/api/v1/user", access.ScopeWrite, authUser, "Update profile", (*Server).apiPutUser},
15 15 {http.MethodGet, "/api/v1/user/export", access.ScopeRead, authUser, "Export account", (*Server).apiExport},
16 {http.MethodGet, "/api/v1/users/{username}", access.ScopeRead, authUser, "User profile", (*Server).apiUserByName},
16 {http.MethodGet, "/api/v1/users/{username}", access.ScopeRead, authOptional, "User profile", (*Server).apiUserByName},
17 17 {http.MethodGet, "/api/v1/user/tokens", access.ScopeRead, authUser, "List access tokens", (*Server).apiListTokens},
18 18 {http.MethodPost, "/api/v1/user/tokens", access.ScopeWrite, authUser, "Create access token", (*Server).apiCreateToken},
19 19 {http.MethodDelete, "/api/v1/user/tokens/{id}", access.ScopeWrite, authUser, "Revoke access token", (*Server).apiDeleteToken},
@@ -106,6 +106,7 @@ var apiCatalog = []apiRoute{
106 106 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines", access.ScopeWrite, authUser, "Start pipeline", (*Server).apiPipelines},
107 107 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}", access.ScopeRead, authUser, "Get pipeline", (*Server).apiPipeline},
108 108 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/cancel", access.ScopeWrite, authUser, "Cancel pipeline", (*Server).apiCancelPipeline},
109 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/retry", access.ScopeWrite, authUser, "Retry pipeline", (*Server).apiRetryPipeline},
109 110 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs", access.ScopeRead, authUser, "List jobs", (*Server).apiJobs},
110 111 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}", access.ScopeRead, authUser, "Get job", (*Server).apiJob},
111 112 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/log", access.ScopeRead, authUser, "Job log", (*Server).apiJobLog},
@@ -13,7 +13,7 @@ var apiCatalog = []apiRoute{
13 {http.MethodGet, "/api/v1/user", access.ScopeRead, authUser, "Current user", (*Server).apiGetUser},
13 {http.MethodGet, "/api/v1/user", access.ScopeRead, authUser, "Current user", (*Server).apiGetUser},
14 {http.MethodPut, "/api/v1/user", access.ScopeWrite, authUser, "Update profile", (*Server).apiPutUser},
14 {http.MethodPut, "/api/v1/user", access.ScopeWrite, authUser, "Update profile", (*Server).apiPutUser},
15 {http.MethodGet, "/api/v1/user/export", access.ScopeRead, authUser, "Export account", (*Server).apiExport},
15 {http.MethodGet, "/api/v1/user/export", access.ScopeRead, authUser, "Export account", (*Server).apiExport},
16 {http.MethodGet, "/api/v1/users/{username}", access.ScopeRead, authUser, "User profile", (*Server).apiUserByName},
16 {http.MethodGet, "/api/v1/users/{username}", access.ScopeRead, authOptional, "User profile", (*Server).apiUserByName},
17 {http.MethodGet, "/api/v1/user/tokens", access.ScopeRead, authUser, "List access tokens", (*Server).apiListTokens},
17 {http.MethodGet, "/api/v1/user/tokens", access.ScopeRead, authUser, "List access tokens", (*Server).apiListTokens},
18 {http.MethodPost, "/api/v1/user/tokens", access.ScopeWrite, authUser, "Create access token", (*Server).apiCreateToken},
18 {http.MethodPost, "/api/v1/user/tokens", access.ScopeWrite, authUser, "Create access token", (*Server).apiCreateToken},
19 {http.MethodDelete, "/api/v1/user/tokens/{id}", access.ScopeWrite, authUser, "Revoke access token", (*Server).apiDeleteToken},
19 {http.MethodDelete, "/api/v1/user/tokens/{id}", access.ScopeWrite, authUser, "Revoke access token", (*Server).apiDeleteToken},
@@ -106,6 +106,7 @@ var apiCatalog = []apiRoute{
106 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines", access.ScopeWrite, authUser, "Start pipeline", (*Server).apiPipelines},
106 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines", access.ScopeWrite, authUser, "Start pipeline", (*Server).apiPipelines},
107 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}", access.ScopeRead, authUser, "Get pipeline", (*Server).apiPipeline},
107 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}", access.ScopeRead, authUser, "Get pipeline", (*Server).apiPipeline},
108 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/cancel", access.ScopeWrite, authUser, "Cancel pipeline", (*Server).apiCancelPipeline},
108 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/cancel", access.ScopeWrite, authUser, "Cancel pipeline", (*Server).apiCancelPipeline},
109 {http.MethodPost, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/retry", access.ScopeWrite, authUser, "Retry pipeline", (*Server).apiRetryPipeline},
109 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs", access.ScopeRead, authUser, "List jobs", (*Server).apiJobs},
110 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs", access.ScopeRead, authUser, "List jobs", (*Server).apiJobs},
110 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}", access.ScopeRead, authUser, "Get job", (*Server).apiJob},
111 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}", access.ScopeRead, authUser, "Get job", (*Server).apiJob},
111 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/log", access.ScopeRead, authUser, "Job log", (*Server).apiJobLog},
112 {http.MethodGet, "/api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/log", access.ScopeRead, authUser, "Job log", (*Server).apiJobLog},
internal/server/api_test.go +1 −0
@@ -61,6 +61,7 @@ func TestAPICatalogCoversResources(t *testing.T) {
61 61 "POST /api/v1/projects/{owner}/{repo}/merge_requests/{number}/suggestions\n",
62 62 "POST /api/v1/projects/{owner}/{repo}/merge_requests/{number}/merge\n",
63 63 "POST /api/v1/projects/{owner}/{repo}/pipelines\n",
64 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/retry\n",
64 65 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/play\n",
65 66 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/retry\n",
66 67 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/cancel\n",
@@ -61,6 +61,7 @@ func TestAPICatalogCoversResources(t *testing.T) {
61 "POST /api/v1/projects/{owner}/{repo}/merge_requests/{number}/suggestions\n",
61 "POST /api/v1/projects/{owner}/{repo}/merge_requests/{number}/suggestions\n",
62 "POST /api/v1/projects/{owner}/{repo}/merge_requests/{number}/merge\n",
62 "POST /api/v1/projects/{owner}/{repo}/merge_requests/{number}/merge\n",
63 "POST /api/v1/projects/{owner}/{repo}/pipelines\n",
63 "POST /api/v1/projects/{owner}/{repo}/pipelines\n",
64 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/retry\n",
64 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/play\n",
65 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/play\n",
65 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/retry\n",
66 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/retry\n",
66 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/cancel\n",
67 "POST /api/v1/projects/{owner}/{repo}/pipelines/{id}/jobs/{job}/cancel\n",
internal/server/archive_test.go added +195 −0
@@ -0,0 +1,195 @@
1 package server
2
3 import (
4 "archive/tar"
5 "archive/zip"
6 "bytes"
7 "compress/gzip"
8 "crypto/sha256"
9 "encoding/hex"
10 "io"
11 "net/http"
12 "net/http/cookiejar"
13 "net/http/httptest"
14 "net/url"
15 "os/exec"
16 "path/filepath"
17 "strings"
18 "testing"
19
20 "gitlab.com/Timfa/bluegit/internal/auth"
21 "gitlab.com/Timfa/bluegit/internal/config"
22 "gitlab.com/Timfa/bluegit/internal/store"
23 )
24
25 func TestCommitArchivePublicAndStable(t *testing.T) {
26 if _, err := exec.LookPath("git"); err != nil {
27 t.Skip("git ontbreekt")
28 }
29 storage := t.TempDir()
30 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
31 if err != nil {
32 t.Fatal(err)
33 }
34 t.Cleanup(func() { _ = st.Close() })
35 cfg := config.Config{
36 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
37 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
38 Git: config.Git{Binary: "git", DefaultBranch: "master"},
39 }
40 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
41 ts := httptest.NewServer(srv.Handler())
42 t.Cleanup(ts.Close)
43 jar, _ := cookiejar.New(nil)
44 tim := &http.Client{Jar: jar}
45 anon := &http.Client{}
46
47 page := read(t, mustGet(t, tim, ts.URL+"/login"))
48 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
49 "csrf": {csrfOf(t, page)}, "name": {"archief"}, "visibility": {"public"},
50 }))
51 page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{
52 "csrf": {csrfOf(t, page)}, "name": {"laptop"},
53 }))
54 token := between(page, `<p class="code">`, "</p>")
55 work := t.TempDir()
56 git(t, work, "init", "-b", "master")
57 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
58 git(t, work, "config", "user.name", "tim")
59 writeFile(t, filepath.Join(work, "hello.txt"), "alpha\n")
60 git(t, work, "add", "hello.txt")
61 git(t, work, "commit", "-m", "start")
62 remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/archief.git"
63 git(t, work, "remote", "add", "origin", remote)
64 git(t, work, "push", "-u", "origin", "master")
65 sha := strings.TrimSpace(gitOutOK(t, work, "rev-parse", "HEAD"))
66
67 tarURL := ts.URL + "/tim/archief/-/archive/" + sha + "/archief-" + sha + ".tar.gz"
68 first := getBody(t, anon, tarURL)
69 second := getBody(t, anon, tarURL)
70 if first.code != http.StatusOK || !bytes.Equal(first.body, second.body) {
71 t.Fatalf("tar.gz %d, gelijk %v, lengte %d", first.code, bytes.Equal(first.body, second.body), len(first.body))
72 }
73 if len(first.body) < 2 || first.body[0] != 0x1f || first.body[1] != 0x8b {
74 t.Fatal("geen gzip")
75 }
76 if !strings.Contains(first.header.Get("Content-Disposition"), "archief-"+sha+".tar.gz") {
77 t.Fatalf("bestandsnaam: %s", first.header.Get("Content-Disposition"))
78 }
79 sum := sha256.Sum256(first.body)
80 if hex.EncodeToString(sum[:]) != hex.EncodeToString(sha256Sum(second.body)) {
81 t.Fatal("sha256 verschilt tussen twee downloads")
82 }
83 names := tarNames(t, first.body)
84 want := "archief-" + sha + "/hello.txt"
85 if !containsString(names, want) {
86 t.Fatalf("tar mist %s in %v", want, names)
87 }
88
89 zipURL := ts.URL + "/tim/archief/-/archive/" + sha + "/archief-" + sha + ".zip"
90 zipRes := getBody(t, anon, zipURL)
91 if zipRes.code != http.StatusOK || len(zipRes.body) < 2 || zipRes.body[0] != 'P' || zipRes.body[1] != 'K' {
92 t.Fatalf("zip %d", zipRes.code)
93 }
94 zr, err := zip.NewReader(bytes.NewReader(zipRes.body), int64(len(zipRes.body)))
95 if err != nil {
96 t.Fatal(err)
97 }
98 found := false
99 for _, f := range zr.File {
100 if f.Name == want {
101 found = true
102 }
103 }
104 if !found {
105 t.Fatalf("zip mist %s", want)
106 }
107 again := getBody(t, anon, zipURL)
108 if !bytes.Equal(zipRes.body, again.body) {
109 t.Fatal("zip verschilt tussen twee downloads")
110 }
111
112 for _, raw := range []string{
113 ts.URL + "/tim/archief/-/archive/" + sha[:12] + "/archief.tar.gz",
114 ts.URL + "/tim/archief/-/archive/master/archief-master.tar.gz",
115 ts.URL + "/tim/archief/-/archive/" + sha + "/archief-" + sha + ".tar.bz2",
116 ts.URL + "/tim/archief/-/archive/" + strings.Repeat("ab", 20) + "/archief.tar.gz",
117 } {
118 res := getBody(t, anon, raw)
119 if res.code != http.StatusNotFound {
120 t.Fatalf("%s: %d", raw, res.code)
121 }
122 }
123
124 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
125 "csrf": {csrfOf(t, page)}, "name": {"geheim"}, "visibility": {"private"},
126 }))
127 secret := t.TempDir()
128 git(t, secret, "init", "-b", "master")
129 git(t, secret, "config", "user.email", "tim@users.git.timfalken.com")
130 git(t, secret, "config", "user.name", "tim")
131 writeFile(t, filepath.Join(secret, "hello.txt"), "geheim\n")
132 git(t, secret, "add", "hello.txt")
133 git(t, secret, "commit", "-m", "geheim")
134 privRemote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/geheim.git"
135 git(t, secret, "remote", "add", "origin", privRemote)
136 git(t, secret, "push", "-u", "origin", "master")
137 privSHA := strings.TrimSpace(gitOutOK(t, secret, "rev-parse", "HEAD"))
138 hidden := getBody(t, anon, ts.URL+"/tim/geheim/-/archive/"+privSHA+"/geheim-"+privSHA+".tar.gz")
139 if hidden.code != http.StatusNotFound {
140 t.Fatalf("privé-archief: %d", hidden.code)
141 }
142 }
143
144 type bodyResult struct {
145 code int
146 header http.Header
147 body []byte
148 }
149
150 func getBody(t *testing.T, c *http.Client, raw string) bodyResult {
151 t.Helper()
152 res := mustGet(t, c, raw)
153 defer res.Body.Close()
154 body, err := io.ReadAll(res.Body)
155 if err != nil {
156 t.Fatal(err)
157 }
158 return bodyResult{code: res.StatusCode, header: res.Header, body: body}
159 }
160
161 func tarNames(t *testing.T, gz []byte) []string {
162 t.Helper()
163 zr, err := gzip.NewReader(bytes.NewReader(gz))
164 if err != nil {
165 t.Fatal(err)
166 }
167 defer zr.Close()
168 tr := tar.NewReader(zr)
169 var names []string
170 for {
171 hdr, err := tr.Next()
172 if err == io.EOF {
173 break
174 }
175 if err != nil {
176 t.Fatal(err)
177 }
178 names = append(names, hdr.Name)
179 }
180 return names
181 }
182
183 func sha256Sum(b []byte) []byte {
184 sum := sha256.Sum256(b)
185 return sum[:]
186 }
187
188 func containsString(list []string, want string) bool {
189 for _, item := range list {
190 if item == want {
191 return true
192 }
193 }
194 return false
195 }
@@ -0,0 +1,195 @@
1package server
2
3import (
4 "archive/tar"
5 "archive/zip"
6 "bytes"
7 "compress/gzip"
8 "crypto/sha256"
9 "encoding/hex"
10 "io"
11 "net/http"
12 "net/http/cookiejar"
13 "net/http/httptest"
14 "net/url"
15 "os/exec"
16 "path/filepath"
17 "strings"
18 "testing"
19
20 "gitlab.com/Timfa/bluegit/internal/auth"
21 "gitlab.com/Timfa/bluegit/internal/config"
22 "gitlab.com/Timfa/bluegit/internal/store"
23)
24
25func TestCommitArchivePublicAndStable(t *testing.T) {
26 if _, err := exec.LookPath("git"); err != nil {
27 t.Skip("git ontbreekt")
28 }
29 storage := t.TempDir()
30 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
31 if err != nil {
32 t.Fatal(err)
33 }
34 t.Cleanup(func() { _ = st.Close() })
35 cfg := config.Config{
36 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
37 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
38 Git: config.Git{Binary: "git", DefaultBranch: "master"},
39 }
40 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
41 ts := httptest.NewServer(srv.Handler())
42 t.Cleanup(ts.Close)
43 jar, _ := cookiejar.New(nil)
44 tim := &http.Client{Jar: jar}
45 anon := &http.Client{}
46
47 page := read(t, mustGet(t, tim, ts.URL+"/login"))
48 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
49 "csrf": {csrfOf(t, page)}, "name": {"archief"}, "visibility": {"public"},
50 }))
51 page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{
52 "csrf": {csrfOf(t, page)}, "name": {"laptop"},
53 }))
54 token := between(page, `<p class="code">`, "</p>")
55 work := t.TempDir()
56 git(t, work, "init", "-b", "master")
57 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
58 git(t, work, "config", "user.name", "tim")
59 writeFile(t, filepath.Join(work, "hello.txt"), "alpha\n")
60 git(t, work, "add", "hello.txt")
61 git(t, work, "commit", "-m", "start")
62 remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/archief.git"
63 git(t, work, "remote", "add", "origin", remote)
64 git(t, work, "push", "-u", "origin", "master")
65 sha := strings.TrimSpace(gitOutOK(t, work, "rev-parse", "HEAD"))
66
67 tarURL := ts.URL + "/tim/archief/-/archive/" + sha + "/archief-" + sha + ".tar.gz"
68 first := getBody(t, anon, tarURL)
69 second := getBody(t, anon, tarURL)
70 if first.code != http.StatusOK || !bytes.Equal(first.body, second.body) {
71 t.Fatalf("tar.gz %d, gelijk %v, lengte %d", first.code, bytes.Equal(first.body, second.body), len(first.body))
72 }
73 if len(first.body) < 2 || first.body[0] != 0x1f || first.body[1] != 0x8b {
74 t.Fatal("geen gzip")
75 }
76 if !strings.Contains(first.header.Get("Content-Disposition"), "archief-"+sha+".tar.gz") {
77 t.Fatalf("bestandsnaam: %s", first.header.Get("Content-Disposition"))
78 }
79 sum := sha256.Sum256(first.body)
80 if hex.EncodeToString(sum[:]) != hex.EncodeToString(sha256Sum(second.body)) {
81 t.Fatal("sha256 verschilt tussen twee downloads")
82 }
83 names := tarNames(t, first.body)
84 want := "archief-" + sha + "/hello.txt"
85 if !containsString(names, want) {
86 t.Fatalf("tar mist %s in %v", want, names)
87 }
88
89 zipURL := ts.URL + "/tim/archief/-/archive/" + sha + "/archief-" + sha + ".zip"
90 zipRes := getBody(t, anon, zipURL)
91 if zipRes.code != http.StatusOK || len(zipRes.body) < 2 || zipRes.body[0] != 'P' || zipRes.body[1] != 'K' {
92 t.Fatalf("zip %d", zipRes.code)
93 }
94 zr, err := zip.NewReader(bytes.NewReader(zipRes.body), int64(len(zipRes.body)))
95 if err != nil {
96 t.Fatal(err)
97 }
98 found := false
99 for _, f := range zr.File {
100 if f.Name == want {
101 found = true
102 }
103 }
104 if !found {
105 t.Fatalf("zip mist %s", want)
106 }
107 again := getBody(t, anon, zipURL)
108 if !bytes.Equal(zipRes.body, again.body) {
109 t.Fatal("zip verschilt tussen twee downloads")
110 }
111
112 for _, raw := range []string{
113 ts.URL + "/tim/archief/-/archive/" + sha[:12] + "/archief.tar.gz",
114 ts.URL + "/tim/archief/-/archive/master/archief-master.tar.gz",
115 ts.URL + "/tim/archief/-/archive/" + sha + "/archief-" + sha + ".tar.bz2",
116 ts.URL + "/tim/archief/-/archive/" + strings.Repeat("ab", 20) + "/archief.tar.gz",
117 } {
118 res := getBody(t, anon, raw)
119 if res.code != http.StatusNotFound {
120 t.Fatalf("%s: %d", raw, res.code)
121 }
122 }
123
124 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
125 "csrf": {csrfOf(t, page)}, "name": {"geheim"}, "visibility": {"private"},
126 }))
127 secret := t.TempDir()
128 git(t, secret, "init", "-b", "master")
129 git(t, secret, "config", "user.email", "tim@users.git.timfalken.com")
130 git(t, secret, "config", "user.name", "tim")
131 writeFile(t, filepath.Join(secret, "hello.txt"), "geheim\n")
132 git(t, secret, "add", "hello.txt")
133 git(t, secret, "commit", "-m", "geheim")
134 privRemote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/geheim.git"
135 git(t, secret, "remote", "add", "origin", privRemote)
136 git(t, secret, "push", "-u", "origin", "master")
137 privSHA := strings.TrimSpace(gitOutOK(t, secret, "rev-parse", "HEAD"))
138 hidden := getBody(t, anon, ts.URL+"/tim/geheim/-/archive/"+privSHA+"/geheim-"+privSHA+".tar.gz")
139 if hidden.code != http.StatusNotFound {
140 t.Fatalf("privé-archief: %d", hidden.code)
141 }
142}
143
144type bodyResult struct {
145 code int
146 header http.Header
147 body []byte
148}
149
150func getBody(t *testing.T, c *http.Client, raw string) bodyResult {
151 t.Helper()
152 res := mustGet(t, c, raw)
153 defer res.Body.Close()
154 body, err := io.ReadAll(res.Body)
155 if err != nil {
156 t.Fatal(err)
157 }
158 return bodyResult{code: res.StatusCode, header: res.Header, body: body}
159}
160
161func tarNames(t *testing.T, gz []byte) []string {
162 t.Helper()
163 zr, err := gzip.NewReader(bytes.NewReader(gz))
164 if err != nil {
165 t.Fatal(err)
166 }
167 defer zr.Close()
168 tr := tar.NewReader(zr)
169 var names []string
170 for {
171 hdr, err := tr.Next()
172 if err == io.EOF {
173 break
174 }
175 if err != nil {
176 t.Fatal(err)
177 }
178 names = append(names, hdr.Name)
179 }
180 return names
181}
182
183func sha256Sum(b []byte) []byte {
184 sum := sha256.Sum256(b)
185 return sum[:]
186}
187
188func containsString(list []string, want string) bool {
189 for _, item := range list {
190 if item == want {
191 return true
192 }
193 }
194 return false
195}
internal/server/branch_page_test.go added +171 −0
@@ -0,0 +1,171 @@
1 package server
2
3 import (
4 "io"
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 "time"
15
16 "gitlab.com/Timfa/bluegit/internal/auth"
17 "gitlab.com/Timfa/bluegit/internal/config"
18 "gitlab.com/Timfa/bluegit/internal/store"
19 )
20
21 func TestBranchIsStale(t *testing.T) {
22 now := time.Date(2026, 10, 23, 12, 0, 0, 0, time.UTC)
23 old := now.Add(-91 * 24 * time.Hour).Unix()
24 fresh := now.Add(-10 * 24 * time.Hour).Unix()
25 if !branchIsStale(old, false, now) {
26 t.Fatal("een branch zonder commit in drie maanden is inactief")
27 }
28 if branchIsStale(old, true, now) {
29 t.Fatal("de standaardbranch blijft actief")
30 }
31 if branchIsStale(fresh, false, now) {
32 t.Fatal("een recente branch is actief")
33 }
34 if branchIsStale(0, false, now) {
35 t.Fatal("een branch zonder datum is actief")
36 }
37 }
38
39 func TestBranchGroupsAndArchive(t *testing.T) {
40 if _, err := exec.LookPath("git"); err != nil {
41 t.Skip("git ontbreekt")
42 }
43 storage := t.TempDir()
44 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
45 if err != nil {
46 t.Fatal(err)
47 }
48 t.Cleanup(func() { _ = st.Close() })
49 cfg := config.Config{
50 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
51 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
52 Git: config.Git{Binary: "git", DefaultBranch: "master"},
53 }
54 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
55 ts := httptest.NewServer(srv.Handler())
56 t.Cleanup(ts.Close)
57 jar, _ := cookiejar.New(nil)
58 tim := &http.Client{Jar: jar}
59 page := read(t, mustGet(t, tim, ts.URL+"/login"))
60 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
61 "csrf": {csrfOf(t, page)}, "name": {"groepen"}, "visibility": {"public"},
62 }))
63 page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{
64 "csrf": {csrfOf(t, page)}, "name": {"laptop"},
65 }))
66 token := between(page, `<p class="code">`, "</p>")
67 remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/groepen.git"
68 work := t.TempDir()
69 git(t, work, "init", "-b", "master")
70 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
71 git(t, work, "config", "user.name", "tim")
72 writeFile(t, filepath.Join(work, "hello.txt"), "alpha\n")
73 git(t, work, "add", "hello.txt")
74 git(t, work, "commit", "-m", "start")
75 git(t, work, "remote", "add", "origin", remote)
76 git(t, work, "push", "-u", "origin", "master")
77
78 git(t, work, "checkout", "-b", "vers")
79 writeFile(t, filepath.Join(work, "hello.txt"), "beta\n")
80 git(t, work, "add", "hello.txt")
81 git(t, work, "commit", "-m", "vers-onderwerp")
82 git(t, work, "push", "-u", "origin", "vers")
83
84 git(t, work, "checkout", "-b", "oud", "master")
85 writeFile(t, filepath.Join(work, "hello.txt"), "oud\n")
86 git(t, work, "add", "hello.txt")
87 commitAt(t, work, "oud-onderwerp", "2020-01-15T12:00:00")
88 git(t, work, "push", "-u", "origin", "oud")
89
90 overview := read(t, mustGet(t, tim, ts.URL+"/tim/groepen/-/branches"))
91 for _, want := range []string{
92 `class="on"`, "Overview", "Active branches", "Stale branches",
93 `data-name="master"`, `data-name="vers"`, `data-name="oud"`,
94 "Filter by branch name", "New branch", "default",
95 `data-copy="oud"`, "Create MR", "vers-onderwerp", "oud-onderwerp",
96 "/-/branches/archive?name=oud&amp;format=zip",
97 "/-/branches/archive?name=oud&amp;format=tar.gz",
98 "/-/merge-requests/new?source=oud&amp;target=master",
99 } {
100 if !strings.Contains(overview, want) {
101 t.Fatalf("overzicht mist %q", want)
102 }
103 }
104 if strings.Contains(overview, `data-delete="master"`) {
105 t.Fatal("de standaardbranch heeft een verwijderknop")
106 }
107 if !strings.Contains(overview, `data-delete="oud"`) || !strings.Contains(overview, `data-delete="vers"`) {
108 t.Fatal("een gewone branch mist de verwijderknop")
109 }
110 oudAt := strings.Index(overview, `data-name="oud"`)
111 staleAt := strings.Index(overview, "Stale branches")
112 activeAt := strings.Index(overview, "Active branches")
113 if activeAt < 0 || staleAt < activeAt || oudAt < staleAt {
114 t.Fatalf("oud hoort in de inactieve groep:\n%s", overview)
115 }
116
117 active := read(t, mustGet(t, tim, ts.URL+"/tim/groepen/-/branches?state=active"))
118 if strings.Contains(active, `data-name="oud"`) || strings.Contains(active, "Stale branches") || !strings.Contains(active, `data-name="master"`) {
119 t.Fatalf("actief:\n%s", active)
120 }
121 stale := read(t, mustGet(t, tim, ts.URL+"/tim/groepen/-/branches?state=stale"))
122 if !strings.Contains(stale, `data-name="oud"`) || strings.Contains(stale, `data-name="master"`) || strings.Contains(stale, "Active branches") {
123 t.Fatalf("inactief:\n%s", stale)
124 }
125 if !strings.Contains(stale, `state=stale"`) || !strings.Contains(stale, `class="on"`) {
126 t.Fatalf("tab inactief:\n%s", stale)
127 }
128
129 zipRes := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=oud&format=zip")
130 zipBody, err := io.ReadAll(zipRes.Body)
131 zipRes.Body.Close()
132 if err != nil {
133 t.Fatal(err)
134 }
135 if zipRes.StatusCode != http.StatusOK || len(zipBody) < 2 || zipBody[0] != 'P' || zipBody[1] != 'K' {
136 t.Fatalf("zip status %d lengte %d", zipRes.StatusCode, len(zipBody))
137 }
138 if !strings.Contains(zipRes.Header.Get("Content-Disposition"), "groepen-oud.zip") {
139 t.Fatalf("bestandsnaam: %s", zipRes.Header.Get("Content-Disposition"))
140 }
141 tarRes := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=vers&format=tar.gz")
142 tarBody, err := io.ReadAll(tarRes.Body)
143 tarRes.Body.Close()
144 if err != nil {
145 t.Fatal(err)
146 }
147 if tarRes.StatusCode != http.StatusOK || len(tarBody) < 2 || tarBody[0] != 0x1f || tarBody[1] != 0x8b {
148 t.Fatalf("tar.gz status %d", tarRes.StatusCode)
149 }
150 missing := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=geen&format=zip")
151 missing.Body.Close()
152 if missing.StatusCode != http.StatusNotFound {
153 t.Fatalf("ontbrekende branch: %d", missing.StatusCode)
154 }
155 bad := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=master&format=exe")
156 bad.Body.Close()
157 if bad.StatusCode != http.StatusNotFound {
158 t.Fatalf("formaat: %d", bad.StatusCode)
159 }
160 }
161
162 func commitAt(t *testing.T, dir, msg, when string) {
163 t.Helper()
164 cmd := exec.Command("git", "-c", "commit.gpgsign=false", "commit", "-m", msg)
165 cmd.Dir = dir
166 cmd.Env = append(os.Environ(), "GIT_AUTHOR_DATE="+when, "GIT_COMMITTER_DATE="+when)
167 out, err := cmd.CombinedOutput()
168 if err != nil {
169 t.Fatalf("commit: %v\n%s", err, out)
170 }
171 }
@@ -0,0 +1,171 @@
1package server
2
3import (
4 "io"
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 "time"
15
16 "gitlab.com/Timfa/bluegit/internal/auth"
17 "gitlab.com/Timfa/bluegit/internal/config"
18 "gitlab.com/Timfa/bluegit/internal/store"
19)
20
21func TestBranchIsStale(t *testing.T) {
22 now := time.Date(2026, 10, 23, 12, 0, 0, 0, time.UTC)
23 old := now.Add(-91 * 24 * time.Hour).Unix()
24 fresh := now.Add(-10 * 24 * time.Hour).Unix()
25 if !branchIsStale(old, false, now) {
26 t.Fatal("een branch zonder commit in drie maanden is inactief")
27 }
28 if branchIsStale(old, true, now) {
29 t.Fatal("de standaardbranch blijft actief")
30 }
31 if branchIsStale(fresh, false, now) {
32 t.Fatal("een recente branch is actief")
33 }
34 if branchIsStale(0, false, now) {
35 t.Fatal("een branch zonder datum is actief")
36 }
37}
38
39func TestBranchGroupsAndArchive(t *testing.T) {
40 if _, err := exec.LookPath("git"); err != nil {
41 t.Skip("git ontbreekt")
42 }
43 storage := t.TempDir()
44 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
45 if err != nil {
46 t.Fatal(err)
47 }
48 t.Cleanup(func() { _ = st.Close() })
49 cfg := config.Config{
50 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
51 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
52 Git: config.Git{Binary: "git", DefaultBranch: "master"},
53 }
54 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
55 ts := httptest.NewServer(srv.Handler())
56 t.Cleanup(ts.Close)
57 jar, _ := cookiejar.New(nil)
58 tim := &http.Client{Jar: jar}
59 page := read(t, mustGet(t, tim, ts.URL+"/login"))
60 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
61 "csrf": {csrfOf(t, page)}, "name": {"groepen"}, "visibility": {"public"},
62 }))
63 page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{
64 "csrf": {csrfOf(t, page)}, "name": {"laptop"},
65 }))
66 token := between(page, `<p class="code">`, "</p>")
67 remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/groepen.git"
68 work := t.TempDir()
69 git(t, work, "init", "-b", "master")
70 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
71 git(t, work, "config", "user.name", "tim")
72 writeFile(t, filepath.Join(work, "hello.txt"), "alpha\n")
73 git(t, work, "add", "hello.txt")
74 git(t, work, "commit", "-m", "start")
75 git(t, work, "remote", "add", "origin", remote)
76 git(t, work, "push", "-u", "origin", "master")
77
78 git(t, work, "checkout", "-b", "vers")
79 writeFile(t, filepath.Join(work, "hello.txt"), "beta\n")
80 git(t, work, "add", "hello.txt")
81 git(t, work, "commit", "-m", "vers-onderwerp")
82 git(t, work, "push", "-u", "origin", "vers")
83
84 git(t, work, "checkout", "-b", "oud", "master")
85 writeFile(t, filepath.Join(work, "hello.txt"), "oud\n")
86 git(t, work, "add", "hello.txt")
87 commitAt(t, work, "oud-onderwerp", "2020-01-15T12:00:00")
88 git(t, work, "push", "-u", "origin", "oud")
89
90 overview := read(t, mustGet(t, tim, ts.URL+"/tim/groepen/-/branches"))
91 for _, want := range []string{
92 `class="on"`, "Overview", "Active branches", "Stale branches",
93 `data-name="master"`, `data-name="vers"`, `data-name="oud"`,
94 "Filter by branch name", "New branch", "default",
95 `data-copy="oud"`, "Create MR", "vers-onderwerp", "oud-onderwerp",
96 "/-/branches/archive?name=oud&amp;format=zip",
97 "/-/branches/archive?name=oud&amp;format=tar.gz",
98 "/-/merge-requests/new?source=oud&amp;target=master",
99 } {
100 if !strings.Contains(overview, want) {
101 t.Fatalf("overzicht mist %q", want)
102 }
103 }
104 if strings.Contains(overview, `data-delete="master"`) {
105 t.Fatal("de standaardbranch heeft een verwijderknop")
106 }
107 if !strings.Contains(overview, `data-delete="oud"`) || !strings.Contains(overview, `data-delete="vers"`) {
108 t.Fatal("een gewone branch mist de verwijderknop")
109 }
110 oudAt := strings.Index(overview, `data-name="oud"`)
111 staleAt := strings.Index(overview, "Stale branches")
112 activeAt := strings.Index(overview, "Active branches")
113 if activeAt < 0 || staleAt < activeAt || oudAt < staleAt {
114 t.Fatalf("oud hoort in de inactieve groep:\n%s", overview)
115 }
116
117 active := read(t, mustGet(t, tim, ts.URL+"/tim/groepen/-/branches?state=active"))
118 if strings.Contains(active, `data-name="oud"`) || strings.Contains(active, "Stale branches") || !strings.Contains(active, `data-name="master"`) {
119 t.Fatalf("actief:\n%s", active)
120 }
121 stale := read(t, mustGet(t, tim, ts.URL+"/tim/groepen/-/branches?state=stale"))
122 if !strings.Contains(stale, `data-name="oud"`) || strings.Contains(stale, `data-name="master"`) || strings.Contains(stale, "Active branches") {
123 t.Fatalf("inactief:\n%s", stale)
124 }
125 if !strings.Contains(stale, `state=stale"`) || !strings.Contains(stale, `class="on"`) {
126 t.Fatalf("tab inactief:\n%s", stale)
127 }
128
129 zipRes := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=oud&format=zip")
130 zipBody, err := io.ReadAll(zipRes.Body)
131 zipRes.Body.Close()
132 if err != nil {
133 t.Fatal(err)
134 }
135 if zipRes.StatusCode != http.StatusOK || len(zipBody) < 2 || zipBody[0] != 'P' || zipBody[1] != 'K' {
136 t.Fatalf("zip status %d lengte %d", zipRes.StatusCode, len(zipBody))
137 }
138 if !strings.Contains(zipRes.Header.Get("Content-Disposition"), "groepen-oud.zip") {
139 t.Fatalf("bestandsnaam: %s", zipRes.Header.Get("Content-Disposition"))
140 }
141 tarRes := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=vers&format=tar.gz")
142 tarBody, err := io.ReadAll(tarRes.Body)
143 tarRes.Body.Close()
144 if err != nil {
145 t.Fatal(err)
146 }
147 if tarRes.StatusCode != http.StatusOK || len(tarBody) < 2 || tarBody[0] != 0x1f || tarBody[1] != 0x8b {
148 t.Fatalf("tar.gz status %d", tarRes.StatusCode)
149 }
150 missing := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=geen&format=zip")
151 missing.Body.Close()
152 if missing.StatusCode != http.StatusNotFound {
153 t.Fatalf("ontbrekende branch: %d", missing.StatusCode)
154 }
155 bad := mustGet(t, tim, ts.URL+"/tim/groepen/-/branches/archive?name=master&format=exe")
156 bad.Body.Close()
157 if bad.StatusCode != http.StatusNotFound {
158 t.Fatalf("formaat: %d", bad.StatusCode)
159 }
160}
161
162func commitAt(t *testing.T, dir, msg, when string) {
163 t.Helper()
164 cmd := exec.Command("git", "-c", "commit.gpgsign=false", "commit", "-m", msg)
165 cmd.Dir = dir
166 cmd.Env = append(os.Environ(), "GIT_AUTHOR_DATE="+when, "GIT_COMMITTER_DATE="+when)
167 out, err := cmd.CombinedOutput()
168 if err != nil {
169 t.Fatalf("commit: %v\n%s", err, out)
170 }
171}
internal/server/branches.go +78 −2
@@ -2,6 +2,7 @@ package server
2 2
3 3 import (
4 4 "net/http"
5 "net/url"
5 6 "sort"
6 7 "strconv"
7 8 "strings"
@@ -10,9 +11,13 @@ import (
10 11 "gitlab.com/Timfa/bluegit/internal/access"
11 12 "gitlab.com/Timfa/bluegit/internal/gitrepo"
12 13 "gitlab.com/Timfa/bluegit/internal/i18n"
14 "gitlab.com/Timfa/bluegit/internal/names"
13 15 "gitlab.com/Timfa/bluegit/internal/store"
14 16 )
15 17
18 // Een branch zonder commit in drie maanden is inactief, zoals bij GitLab.
19 const branchStaleAfter = 90 * 24 * time.Hour
20
16 21 func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
17 22 _, repo, role, ok := s.guard(w, r, access.RoleReadonly)
18 23 if !ok {
@@ -21,18 +26,26 @@ func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
21 26 s.absorbMergedMRs(r.Context(), repo)
22 27 v := s.repoView(w, r, repo, role, "title.branches")
23 28 v.Page = "branches"
29 v.Wide = true
24 30 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
25 31 tips, _ := gitrepo.BranchTips(r.Context(), s.Git, dir)
26 32 patterns, _ := s.Store.ProtectedPatterns(r.Context(), repo.ID)
27 33 lang := s.langOf(r)
34 now := time.Now()
28 35 for _, tip := range tips {
29 36 when, title := branchWhen(lang, tip.Date)
37 unix, _ := strconv.ParseInt(strings.TrimSpace(tip.Date), 10, 64)
30 38 row := BranchRow{
31 39 Name: tip.Name, SHA: tip.SHA, Short: shortSHA(tip.SHA),
32 Subject: tip.Subject, When: when, WhenTitle: title,
40 Subject: tip.Subject, When: when, WhenTitle: title, Unix: unix,
33 41 Protected: access.BranchProtected(patterns, tip.Name),
34 42 Default: tip.Name == repo.DefaultBranch,
43 RepoPath: repo.FullPath(),
44 Target: repo.DefaultBranch,
45 ZipURL: branchArchiveURL(repo, tip.Name, "zip"),
46 TarURL: branchArchiveURL(repo, tip.Name, "tar.gz"),
35 47 }
48 row.CanEdit = role.CanWriteCode() && !row.Default && !row.Protected
36 49 if !row.Default && repo.DefaultBranch != "" {
37 50 ahead, behind, err := gitrepo.AheadBehind(r.Context(), s.Git, dir, repo.DefaultBranch, tip.Name)
38 51 if err == nil {
@@ -56,8 +69,32 @@ func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
56 69 if v.Branches[i].Default != v.Branches[j].Default {
57 70 return v.Branches[i].Default
58 71 }
72 if v.Branches[i].Unix != v.Branches[j].Unix {
73 return v.Branches[i].Unix > v.Branches[j].Unix
74 }
59 75 return v.Branches[i].Name < v.Branches[j].Name
60 76 })
77 state := branchTab(r.URL.Query().Get("state"))
78 board := &BranchBoard{State: state}
79 for _, row := range v.Branches {
80 if branchIsStale(row.Unix, row.Default, now) {
81 board.Stale = append(board.Stale, row)
82 } else {
83 board.Active = append(board.Active, row)
84 }
85 }
86 switch state {
87 case "active":
88 board.ShowActive = true
89 case "stale":
90 board.ShowStale = true
91 case "all":
92 board.ShowActive, board.ShowStale = true, true
93 default:
94 board.ShowActive = len(board.Active) > 0 || len(board.Stale) == 0
95 board.ShowStale = len(board.Stale) > 0
96 }
97 v.Branch = board
61 98 tags, _ := gitrepo.Tags(r.Context(), s.Git, dir)
62 99 for _, name := range tags {
63 100 v.Tags = append(v.Tags, TagRow{Name: name})
@@ -65,6 +102,25 @@ func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
65 102 s.render(w, "branches", v)
66 103 }
67 104
105 func (s *Server) branchArchive(w http.ResponseWriter, r *http.Request) {
106 _, repo, _, ok := s.guard(w, r, access.RoleReadonly)
107 if !ok {
108 return
109 }
110 name := r.URL.Query().Get("name")
111 format := r.URL.Query().Get("format")
112 if names.ValidBranch(name) != nil || (format != "zip" && format != "tar.gz") {
113 http.NotFound(w, r)
114 return
115 }
116 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
117 if gitOne(r.Context(), s.Git, dir, "rev-parse", "--verify", "--quiet", "refs/heads/"+name) == "" {
118 http.NotFound(w, r)
119 return
120 }
121 s.writeArchive(w, r, repo, dir, "refs/heads/"+name, name, format)
122 }
123
68 124 func (s *Server) createBranch(w http.ResponseWriter, r *http.Request) {
69 125 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
70 126 if !ok || !s.csrfOK(w, r) {
@@ -101,13 +157,33 @@ func (s *Server) renameBranch(w http.ResponseWriter, r *http.Request) {
101 157 s.redirect(w, r, back, s.tr(r, "flash.branchRenamed"), "")
102 158 }
103 159
160 func branchTab(raw string) string {
161 switch raw {
162 case "active", "stale", "all":
163 return raw
164 default:
165 return "overview"
166 }
167 }
168
169 func branchIsStale(unix int64, isDefault bool, now time.Time) bool {
170 if isDefault || unix <= 0 {
171 return false
172 }
173 return now.Sub(time.Unix(unix, 0)) > branchStaleAfter
174 }
175
176 func branchArchiveURL(repo interface{ FullPath() string }, name, format string) string {
177 return "/" + repo.FullPath() + "/-/branches/archive?name=" + url.QueryEscape(name) + "&format=" + format
178 }
179
104 180 func branchWhen(lang i18n.Lang, unixText string) (short, title string) {
105 181 unix, err := strconv.ParseInt(strings.TrimSpace(unixText), 10, 64)
106 182 if err != nil || unix <= 0 {
107 183 return "", ""
108 184 }
109 185 at := time.Unix(unix, 0).UTC()
110 return i18n.ShortAgo(lang, unix), at.Format("2006-01-02 15:04 UTC")
186 return i18n.Ago(lang, unix), at.Format("2006-01-02 15:04 UTC")
111 187 }
112 188
113 189 // branchLocked weigert de standaardbranch en elke beschermde branch, ook voor een beheerder.
@@ -2,6 +2,7 @@ package server
2
2
3import (
3import (
4 "net/http"
4 "net/http"
5 "net/url"
5 "sort"
6 "sort"
6 "strconv"
7 "strconv"
7 "strings"
8 "strings"
@@ -10,9 +11,13 @@ import (
10 "gitlab.com/Timfa/bluegit/internal/access"
11 "gitlab.com/Timfa/bluegit/internal/access"
11 "gitlab.com/Timfa/bluegit/internal/gitrepo"
12 "gitlab.com/Timfa/bluegit/internal/gitrepo"
12 "gitlab.com/Timfa/bluegit/internal/i18n"
13 "gitlab.com/Timfa/bluegit/internal/i18n"
14 "gitlab.com/Timfa/bluegit/internal/names"
13 "gitlab.com/Timfa/bluegit/internal/store"
15 "gitlab.com/Timfa/bluegit/internal/store"
14)
16)
15
17
18// Een branch zonder commit in drie maanden is inactief, zoals bij GitLab.
19const branchStaleAfter = 90 * 24 * time.Hour
20
16func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
21func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
17 _, repo, role, ok := s.guard(w, r, access.RoleReadonly)
22 _, repo, role, ok := s.guard(w, r, access.RoleReadonly)
18 if !ok {
23 if !ok {
@@ -21,18 +26,26 @@ func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
21 s.absorbMergedMRs(r.Context(), repo)
26 s.absorbMergedMRs(r.Context(), repo)
22 v := s.repoView(w, r, repo, role, "title.branches")
27 v := s.repoView(w, r, repo, role, "title.branches")
23 v.Page = "branches"
28 v.Page = "branches"
29 v.Wide = true
24 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
30 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
25 tips, _ := gitrepo.BranchTips(r.Context(), s.Git, dir)
31 tips, _ := gitrepo.BranchTips(r.Context(), s.Git, dir)
26 patterns, _ := s.Store.ProtectedPatterns(r.Context(), repo.ID)
32 patterns, _ := s.Store.ProtectedPatterns(r.Context(), repo.ID)
27 lang := s.langOf(r)
33 lang := s.langOf(r)
34 now := time.Now()
28 for _, tip := range tips {
35 for _, tip := range tips {
29 when, title := branchWhen(lang, tip.Date)
36 when, title := branchWhen(lang, tip.Date)
37 unix, _ := strconv.ParseInt(strings.TrimSpace(tip.Date), 10, 64)
30 row := BranchRow{
38 row := BranchRow{
31 Name: tip.Name, SHA: tip.SHA, Short: shortSHA(tip.SHA),
39 Name: tip.Name, SHA: tip.SHA, Short: shortSHA(tip.SHA),
32 Subject: tip.Subject, When: when, WhenTitle: title,
40 Subject: tip.Subject, When: when, WhenTitle: title, Unix: unix,
33 Protected: access.BranchProtected(patterns, tip.Name),
41 Protected: access.BranchProtected(patterns, tip.Name),
34 Default: tip.Name == repo.DefaultBranch,
42 Default: tip.Name == repo.DefaultBranch,
43 RepoPath: repo.FullPath(),
44 Target: repo.DefaultBranch,
45 ZipURL: branchArchiveURL(repo, tip.Name, "zip"),
46 TarURL: branchArchiveURL(repo, tip.Name, "tar.gz"),
35 }
47 }
48 row.CanEdit = role.CanWriteCode() && !row.Default && !row.Protected
36 if !row.Default && repo.DefaultBranch != "" {
49 if !row.Default && repo.DefaultBranch != "" {
37 ahead, behind, err := gitrepo.AheadBehind(r.Context(), s.Git, dir, repo.DefaultBranch, tip.Name)
50 ahead, behind, err := gitrepo.AheadBehind(r.Context(), s.Git, dir, repo.DefaultBranch, tip.Name)
38 if err == nil {
51 if err == nil {
@@ -56,8 +69,32 @@ func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
56 if v.Branches[i].Default != v.Branches[j].Default {
69 if v.Branches[i].Default != v.Branches[j].Default {
57 return v.Branches[i].Default
70 return v.Branches[i].Default
58 }
71 }
72 if v.Branches[i].Unix != v.Branches[j].Unix {
73 return v.Branches[i].Unix > v.Branches[j].Unix
74 }
59 return v.Branches[i].Name < v.Branches[j].Name
75 return v.Branches[i].Name < v.Branches[j].Name
60 })
76 })
77 state := branchTab(r.URL.Query().Get("state"))
78 board := &BranchBoard{State: state}
79 for _, row := range v.Branches {
80 if branchIsStale(row.Unix, row.Default, now) {
81 board.Stale = append(board.Stale, row)
82 } else {
83 board.Active = append(board.Active, row)
84 }
85 }
86 switch state {
87 case "active":
88 board.ShowActive = true
89 case "stale":
90 board.ShowStale = true
91 case "all":
92 board.ShowActive, board.ShowStale = true, true
93 default:
94 board.ShowActive = len(board.Active) > 0 || len(board.Stale) == 0
95 board.ShowStale = len(board.Stale) > 0
96 }
97 v.Branch = board
61 tags, _ := gitrepo.Tags(r.Context(), s.Git, dir)
98 tags, _ := gitrepo.Tags(r.Context(), s.Git, dir)
62 for _, name := range tags {
99 for _, name := range tags {
63 v.Tags = append(v.Tags, TagRow{Name: name})
100 v.Tags = append(v.Tags, TagRow{Name: name})
@@ -65,6 +102,25 @@ func (s *Server) branches(w http.ResponseWriter, r *http.Request) {
65 s.render(w, "branches", v)
102 s.render(w, "branches", v)
66}
103}
67
104
105func (s *Server) branchArchive(w http.ResponseWriter, r *http.Request) {
106 _, repo, _, ok := s.guard(w, r, access.RoleReadonly)
107 if !ok {
108 return
109 }
110 name := r.URL.Query().Get("name")
111 format := r.URL.Query().Get("format")
112 if names.ValidBranch(name) != nil || (format != "zip" && format != "tar.gz") {
113 http.NotFound(w, r)
114 return
115 }
116 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
117 if gitOne(r.Context(), s.Git, dir, "rev-parse", "--verify", "--quiet", "refs/heads/"+name) == "" {
118 http.NotFound(w, r)
119 return
120 }
121 s.writeArchive(w, r, repo, dir, "refs/heads/"+name, name, format)
122}
123
68func (s *Server) createBranch(w http.ResponseWriter, r *http.Request) {
124func (s *Server) createBranch(w http.ResponseWriter, r *http.Request) {
69 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
125 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
70 if !ok || !s.csrfOK(w, r) {
126 if !ok || !s.csrfOK(w, r) {
@@ -101,13 +157,33 @@ func (s *Server) renameBranch(w http.ResponseWriter, r *http.Request) {
101 s.redirect(w, r, back, s.tr(r, "flash.branchRenamed"), "")
157 s.redirect(w, r, back, s.tr(r, "flash.branchRenamed"), "")
102}
158}
103
159
160func branchTab(raw string) string {
161 switch raw {
162 case "active", "stale", "all":
163 return raw
164 default:
165 return "overview"
166 }
167}
168
169func branchIsStale(unix int64, isDefault bool, now time.Time) bool {
170 if isDefault || unix <= 0 {
171 return false
172 }
173 return now.Sub(time.Unix(unix, 0)) > branchStaleAfter
174}
175
176func branchArchiveURL(repo interface{ FullPath() string }, name, format string) string {
177 return "/" + repo.FullPath() + "/-/branches/archive?name=" + url.QueryEscape(name) + "&format=" + format
178}
179
104func branchWhen(lang i18n.Lang, unixText string) (short, title string) {
180func branchWhen(lang i18n.Lang, unixText string) (short, title string) {
105 unix, err := strconv.ParseInt(strings.TrimSpace(unixText), 10, 64)
181 unix, err := strconv.ParseInt(strings.TrimSpace(unixText), 10, 64)
106 if err != nil || unix <= 0 {
182 if err != nil || unix <= 0 {
107 return "", ""
183 return "", ""
108 }
184 }
109 at := time.Unix(unix, 0).UTC()
185 at := time.Unix(unix, 0).UTC()
110 return i18n.ShortAgo(lang, unix), at.Format("2006-01-02 15:04 UTC")
186 return i18n.Ago(lang, unix), at.Format("2006-01-02 15:04 UTC")
111}
187}
112
188
113// branchLocked weigert de standaardbranch en elke beschermde branch, ook voor een beheerder.
189// branchLocked weigert de standaardbranch en elke beschermde branch, ook voor een beheerder.
internal/server/commit_list.go added +176 −0
@@ -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 @@
1package server
2
3import (
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
17const (
18 commitPageSize = 20
19 commitScanCap = 4000
20)
21
22func 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
39func 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
67func (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
114func 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
121func 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
133func 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
141func 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
152func clipQuery(raw string) string {
153 q := strings.TrimSpace(raw)
154 if len(q) > 200 {
155 q = q[:200]
156 }
157 return q
158}
159
160func 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}
internal/server/commit_list_test.go added +153 −0
@@ -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 @@
1package server
2
3import (
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
20func 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
130func 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
137func 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}
internal/server/events.go +5 −1
@@ -391,7 +391,11 @@ func (s *Server) markIfContained(ctx context.Context, repo store.Repo, user stor
391 391 if err := s.Store.SetMergeRequestStatus(ctx, mr.ID, "merged"); err != nil {
392 392 return mergedSource{}, false
393 393 }
394 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", "")
394 body := ""
395 if shaLike(targetSHA) {
396 body = targetSHA
397 }
398 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", body)
395 399 mr.Status = "merged"
396 400 s.mrHook(repo, mr, user.Username, "merged", "")
397 401 s.closeMergedMR(ctx, repo, user, mr)
@@ -391,7 +391,11 @@ func (s *Server) markIfContained(ctx context.Context, repo store.Repo, user stor
391 if err := s.Store.SetMergeRequestStatus(ctx, mr.ID, "merged"); err != nil {
391 if err := s.Store.SetMergeRequestStatus(ctx, mr.ID, "merged"); err != nil {
392 return mergedSource{}, false
392 return mergedSource{}, false
393 }
393 }
394 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", "")
394 body := ""
395 if shaLike(targetSHA) {
396 body = targetSHA
397 }
398 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", body)
395 mr.Status = "merged"
399 mr.Status = "merged"
396 s.mrHook(repo, mr, user.Username, "merged", "")
400 s.mrHook(repo, mr, user.Username, "merged", "")
397 s.closeMergedMR(ctx, repo, user, mr)
401 s.closeMergedMR(ctx, repo, user, mr)
internal/server/flow_list.go added +394 −0
@@ -0,0 +1,394 @@
1 package server
2
3 import (
4 "net/http"
5 "net/url"
6 "sort"
7 "strconv"
8 "strings"
9 "time"
10
11 "gitlab.com/Timfa/bluegit/internal/access"
12 "gitlab.com/Timfa/bluegit/internal/i18n"
13 "gitlab.com/Timfa/bluegit/internal/store"
14 )
15
16 // FlowBoard is de lijst van merge requests of issues, in de opbouw van GitLab.
17 type FlowBoard struct {
18 Base string
19 Query string
20 Sort string
21 Dir string
22 State string
23 FlipHref string
24 CanNew bool
25 NewHref string
26 NewKey string
27 EmptyKey string
28 Filters bool
29 Label string
30 Assignee string
31 Labels []IssueChoice
32 People []IssueChoice
33 Tabs []FlowTab
34 Rows []FlowRow
35 }
36
37 // FlowTab is één statusfilter met een teller.
38 type FlowTab struct {
39 Href string
40 Key string
41 Count int
42 On bool
43 }
44
45 // FlowRow is één regel in die lijst.
46 type FlowRow struct {
47 Href string
48 Title string
49 Ref string
50 State string
51 StateLabel string
52 Created string
53 Updated string
54 Author string
55 AuthorURL string
56 Target string
57 Comments int
58 PipeStatus string
59 PipeLabel string
60 PipeHref string
61 Draft bool
62 Confidential bool
63 Labels []store.Label
64 People []AccountLink
65 Extra string
66 }
67
68 type flowPerson struct {
69 Name string
70 URL string
71 }
72
73 func (s *Server) flowMRs(r *http.Request, repo store.Repo, role access.Role, all []store.MergeRequest) *FlowBoard {
74 q := strings.TrimSpace(r.URL.Query().Get("q"))
75 sortKey := flowSortKey(r.URL.Query().Get("sort"))
76 dir := flowDirKey(r.URL.Query().Get("dir"))
77 state := flowStateKey(r.URL.Query().Get("state"), true)
78 base := "/" + repo.FullPath() + "/-/merge-requests"
79 people := map[string]flowPerson{}
80
81 var matched []store.MergeRequest
82 openN, mergedN, closedN := 0, 0, 0
83 for _, mr := range all {
84 name, _ := s.flowAuthor(r, mr.Author, people)
85 if !flowHit(q, mr.Title, mr.Description, strconv.FormatInt(mr.Number, 10), "!"+strconv.FormatInt(mr.Number, 10), mr.Author, name, mr.SourceBranch, mr.TargetBranch) {
86 continue
87 }
88 matched = append(matched, mr)
89 switch mr.Status {
90 case "merged":
91 mergedN++
92 case "closed":
93 closedN++
94 default:
95 openN++
96 }
97 }
98 var shown []store.MergeRequest
99 for _, mr := range matched {
100 if state == "all" || mr.Status == state || (state == "open" && mr.Status != "merged" && mr.Status != "closed") {
101 shown = append(shown, mr)
102 }
103 }
104 sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {
105 return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number
106 })
107
108 rows := make([]FlowRow, 0, len(shown))
109 for _, mr := range shown {
110 name, href := s.flowAuthor(r, mr.Author, people)
111 row := FlowRow{
112 Href: base + "/" + strconv.FormatInt(mr.Number, 10),
113 Title: mr.Title,
114 Ref: "!" + strconv.FormatInt(mr.Number, 10),
115 State: flowBadge(mr.Status),
116 StateLabel: s.flowStateLabel(r, mr.Status),
117 Created: s.ago(r, mr.CreatedAt),
118 Updated: s.ago(r, mr.UpdatedAt),
119 Author: name,
120 AuthorURL: href,
121 Draft: mr.Draft,
122 }
123 if row.State == "open" {
124 row.Target = mr.TargetBranch
125 if notes, err := s.Store.ListNotes(r.Context(), mr.ID); err == nil {
126 row.Comments = len(notes)
127 }
128 s.attachFlowPipe(r, repo, mr, &row)
129 }
130 rows = append(rows, row)
131 }
132 board := &FlowBoard{
133 Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,
134 FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), "", ""),
135 CanNew: role.CanWriteCode(),
136 NewHref: base + "/new",
137 NewKey: "list.newMR",
138 EmptyKey: "mr.none",
139 Rows: rows,
140 }
141 board.Tabs = []FlowTab{
142 {Href: flowHref(base, "open", q, sortKey, dir, "", ""), Key: "issue.open", Count: openN, On: state == "open"},
143 {Href: flowHref(base, "merged", q, sortKey, dir, "", ""), Key: "list.merged", Count: mergedN, On: state == "merged"},
144 {Href: flowHref(base, "closed", q, sortKey, dir, "", ""), Key: "issue.closed", Count: closedN, On: state == "closed"},
145 {Href: flowHref(base, "all", q, sortKey, dir, "", ""), Key: "issue.all", Count: openN + mergedN + closedN, On: state == "all"},
146 }
147 return board
148 }
149
150 func (s *Server) flowIssues(r *http.Request, repo store.Repo, b *IssueBoard, all []store.Issue) *FlowBoard {
151 q := b.Query
152 sortKey := flowSortKey(r.URL.Query().Get("sort"))
153 dir := flowDirKey(r.URL.Query().Get("dir"))
154 state := flowStateKey(r.URL.Query().Get("state"), false)
155 base := "/" + repo.FullPath() + "/-/issues"
156 people := map[string]flowPerson{}
157
158 var matched []store.Issue
159 openN, closedN := 0, 0
160 for _, iss := range all {
161 name, _ := s.flowAuthor(r, iss.Author, people)
162 bits := append(issueSearchBits(iss), name)
163 if !flowHit(q, bits...) {
164 continue
165 }
166 matched = append(matched, iss)
167 if iss.Status == "closed" {
168 closedN++
169 } else {
170 openN++
171 }
172 }
173 var shown []store.Issue
174 for _, iss := range matched {
175 if state == "all" || iss.Status == state || (state == "open" && iss.Status != "closed") {
176 shown = append(shown, iss)
177 }
178 }
179 sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {
180 return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number
181 })
182
183 rows := make([]FlowRow, 0, len(shown))
184 for _, iss := range shown {
185 name, href := s.flowAuthor(r, iss.Author, people)
186 var assigned []AccountLink
187 for _, who := range iss.Assignees {
188 n, href := s.flowAuthor(r, who, people)
189 if n == "" {
190 continue
191 }
192 assigned = append(assigned, AccountLink{Name: n, URL: href})
193 }
194 row := FlowRow{
195 Href: base + "/" + strconv.FormatInt(iss.Number, 10),
196 Title: iss.Title,
197 Ref: "#" + strconv.FormatInt(iss.Number, 10),
198 State: flowBadge(iss.Status),
199 StateLabel: s.flowStateLabel(r, iss.Status),
200 Created: s.ago(r, iss.CreatedAt),
201 Updated: s.ago(r, iss.UpdatedAt),
202 Author: name,
203 AuthorURL: href,
204 Confidential: iss.Confidential,
205 Labels: iss.Labels,
206 People: assigned,
207 Extra: iss.Milestone,
208 }
209 if row.State == "open" {
210 if notes, err := s.Store.ListIssueNotes(r.Context(), iss.ID); err == nil {
211 row.Comments = len(notes)
212 }
213 }
214 rows = append(rows, row)
215 }
216 return &FlowBoard{
217 Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,
218 FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), b.Label, b.Assignee),
219 CanNew: b.CanCreate,
220 NewHref: base + "/new",
221 NewKey: "issue.new",
222 EmptyKey: "issue.none",
223 Filters: true,
224 Label: b.Label,
225 Assignee: b.Assignee,
226 Labels: b.Labels,
227 People: b.People,
228 Rows: rows,
229 Tabs: []FlowTab{
230 {Href: flowHref(base, "open", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.open", Count: openN, On: state == "open"},
231 {Href: flowHref(base, "closed", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.closed", Count: closedN, On: state == "closed"},
232 {Href: flowHref(base, "all", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.all", Count: openN + closedN, On: state == "all"},
233 },
234 }
235 }
236
237 func (s *Server) attachFlowPipe(r *http.Request, repo store.Repo, mr store.MergeRequest, row *FlowRow) {
238 p, err := s.Store.LatestMergePipeline(r.Context(), repo.ID, mr.ID)
239 if err != nil {
240 return
241 }
242 jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)
243 st := displayStatus(p.Status, jobs)
244 row.PipeStatus = st
245 row.PipeLabel = s.tr(r, "pipe."+st)
246 row.PipeHref = "/" + repo.FullPath() + "/-/pipelines/" + strconv.FormatInt(p.ID, 10)
247 }
248
249 func (s *Server) flowAuthor(r *http.Request, username string, cache map[string]flowPerson) (string, string) {
250 username = strings.TrimSpace(username)
251 if username == "" {
252 return "", ""
253 }
254 if p, ok := cache[username]; ok {
255 return p.Name, p.URL
256 }
257 p := flowPerson{Name: username}
258 if u, err := s.Store.UserByUsername(r.Context(), username); err == nil && u.ID != 0 {
259 if name := strings.TrimSpace(u.DisplayName); name != "" {
260 p.Name = name
261 } else {
262 p.Name = u.Username
263 }
264 p.URL = "/users/" + u.Username
265 }
266 cache[username] = p
267 return p.Name, p.URL
268 }
269
270 func (s *Server) flowStateLabel(r *http.Request, status string) string {
271 switch status {
272 case "merged":
273 return s.tr(r, "list.merged")
274 case "closed":
275 return s.tr(r, "issue.closed")
276 default:
277 return s.tr(r, "issue.open")
278 }
279 }
280
281 func (s *Server) ago(r *http.Request, t time.Time) string {
282 if t.IsZero() {
283 return ""
284 }
285 return i18n.Ago(s.langOf(r), t.Unix())
286 }
287
288 func issueSearchBits(iss store.Issue) []string {
289 bits := []string{iss.Title, iss.Description, strconv.FormatInt(iss.Number, 10), "#" + strconv.FormatInt(iss.Number, 10), iss.Author, iss.Milestone}
290 bits = append(bits, iss.Assignees...)
291 for _, l := range iss.Labels {
292 bits = append(bits, l.Name)
293 }
294 return bits
295 }
296
297 func flowHit(q string, parts ...string) bool {
298 q = strings.ToLower(strings.TrimSpace(q))
299 if q == "" {
300 return true
301 }
302 q = strings.TrimPrefix(q, "!")
303 q = strings.TrimPrefix(q, "#")
304 for _, p := range parts {
305 if strings.Contains(strings.ToLower(p), q) {
306 return true
307 }
308 }
309 return false
310 }
311
312 func flowSortKey(raw string) string {
313 if raw == "updated" {
314 return "updated"
315 }
316 return "created"
317 }
318
319 func flowDirKey(raw string) string {
320 if raw == "asc" {
321 return "asc"
322 }
323 return "desc"
324 }
325
326 func flipDir(dir string) string {
327 if dir == "asc" {
328 return "desc"
329 }
330 return "asc"
331 }
332
333 func flowStateKey(raw string, merged bool) string {
334 switch raw {
335 case "closed", "all":
336 return raw
337 case "merged":
338 if merged {
339 return "merged"
340 }
341 }
342 return "open"
343 }
344
345 func flowBadge(status string) string {
346 switch status {
347 case "merged", "closed":
348 return status
349 default:
350 return "open"
351 }
352 }
353
354 func flowHref(base, state, q, sortKey, dir, label, assignee string) string {
355 v := url.Values{}
356 v.Set("state", state)
357 if strings.TrimSpace(q) != "" {
358 v.Set("q", q)
359 }
360 if sortKey == "updated" {
361 v.Set("sort", "updated")
362 }
363 if dir == "asc" {
364 v.Set("dir", "asc")
365 }
366 if label != "" {
367 v.Set("label", label)
368 }
369 if assignee != "" {
370 v.Set("assignee", assignee)
371 }
372 return base + "?" + v.Encode()
373 }
374
375 func sortFlow[T any](rows []T, sortKey, dir string, at func(i int) (created, updated time.Time, number int64)) {
376 sort.SliceStable(rows, func(i, j int) bool {
377 ac, au, an := at(i)
378 bc, bu, bn := at(j)
379 a, b := ac, bc
380 if sortKey == "updated" {
381 a, b = au, bu
382 }
383 if dir == "asc" {
384 if a.Equal(b) {
385 return an < bn
386 }
387 return a.Before(b)
388 }
389 if a.Equal(b) {
390 return an > bn
391 }
392 return a.After(b)
393 })
394 }
@@ -0,0 +1,394 @@
1package server
2
3import (
4 "net/http"
5 "net/url"
6 "sort"
7 "strconv"
8 "strings"
9 "time"
10
11 "gitlab.com/Timfa/bluegit/internal/access"
12 "gitlab.com/Timfa/bluegit/internal/i18n"
13 "gitlab.com/Timfa/bluegit/internal/store"
14)
15
16// FlowBoard is de lijst van merge requests of issues, in de opbouw van GitLab.
17type FlowBoard struct {
18 Base string
19 Query string
20 Sort string
21 Dir string
22 State string
23 FlipHref string
24 CanNew bool
25 NewHref string
26 NewKey string
27 EmptyKey string
28 Filters bool
29 Label string
30 Assignee string
31 Labels []IssueChoice
32 People []IssueChoice
33 Tabs []FlowTab
34 Rows []FlowRow
35}
36
37// FlowTab is één statusfilter met een teller.
38type FlowTab struct {
39 Href string
40 Key string
41 Count int
42 On bool
43}
44
45// FlowRow is één regel in die lijst.
46type FlowRow struct {
47 Href string
48 Title string
49 Ref string
50 State string
51 StateLabel string
52 Created string
53 Updated string
54 Author string
55 AuthorURL string
56 Target string
57 Comments int
58 PipeStatus string
59 PipeLabel string
60 PipeHref string
61 Draft bool
62 Confidential bool
63 Labels []store.Label
64 People []AccountLink
65 Extra string
66}
67
68type flowPerson struct {
69 Name string
70 URL string
71}
72
73func (s *Server) flowMRs(r *http.Request, repo store.Repo, role access.Role, all []store.MergeRequest) *FlowBoard {
74 q := strings.TrimSpace(r.URL.Query().Get("q"))
75 sortKey := flowSortKey(r.URL.Query().Get("sort"))
76 dir := flowDirKey(r.URL.Query().Get("dir"))
77 state := flowStateKey(r.URL.Query().Get("state"), true)
78 base := "/" + repo.FullPath() + "/-/merge-requests"
79 people := map[string]flowPerson{}
80
81 var matched []store.MergeRequest
82 openN, mergedN, closedN := 0, 0, 0
83 for _, mr := range all {
84 name, _ := s.flowAuthor(r, mr.Author, people)
85 if !flowHit(q, mr.Title, mr.Description, strconv.FormatInt(mr.Number, 10), "!"+strconv.FormatInt(mr.Number, 10), mr.Author, name, mr.SourceBranch, mr.TargetBranch) {
86 continue
87 }
88 matched = append(matched, mr)
89 switch mr.Status {
90 case "merged":
91 mergedN++
92 case "closed":
93 closedN++
94 default:
95 openN++
96 }
97 }
98 var shown []store.MergeRequest
99 for _, mr := range matched {
100 if state == "all" || mr.Status == state || (state == "open" && mr.Status != "merged" && mr.Status != "closed") {
101 shown = append(shown, mr)
102 }
103 }
104 sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {
105 return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number
106 })
107
108 rows := make([]FlowRow, 0, len(shown))
109 for _, mr := range shown {
110 name, href := s.flowAuthor(r, mr.Author, people)
111 row := FlowRow{
112 Href: base + "/" + strconv.FormatInt(mr.Number, 10),
113 Title: mr.Title,
114 Ref: "!" + strconv.FormatInt(mr.Number, 10),
115 State: flowBadge(mr.Status),
116 StateLabel: s.flowStateLabel(r, mr.Status),
117 Created: s.ago(r, mr.CreatedAt),
118 Updated: s.ago(r, mr.UpdatedAt),
119 Author: name,
120 AuthorURL: href,
121 Draft: mr.Draft,
122 }
123 if row.State == "open" {
124 row.Target = mr.TargetBranch
125 if notes, err := s.Store.ListNotes(r.Context(), mr.ID); err == nil {
126 row.Comments = len(notes)
127 }
128 s.attachFlowPipe(r, repo, mr, &row)
129 }
130 rows = append(rows, row)
131 }
132 board := &FlowBoard{
133 Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,
134 FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), "", ""),
135 CanNew: role.CanWriteCode(),
136 NewHref: base + "/new",
137 NewKey: "list.newMR",
138 EmptyKey: "mr.none",
139 Rows: rows,
140 }
141 board.Tabs = []FlowTab{
142 {Href: flowHref(base, "open", q, sortKey, dir, "", ""), Key: "issue.open", Count: openN, On: state == "open"},
143 {Href: flowHref(base, "merged", q, sortKey, dir, "", ""), Key: "list.merged", Count: mergedN, On: state == "merged"},
144 {Href: flowHref(base, "closed", q, sortKey, dir, "", ""), Key: "issue.closed", Count: closedN, On: state == "closed"},
145 {Href: flowHref(base, "all", q, sortKey, dir, "", ""), Key: "issue.all", Count: openN + mergedN + closedN, On: state == "all"},
146 }
147 return board
148}
149
150func (s *Server) flowIssues(r *http.Request, repo store.Repo, b *IssueBoard, all []store.Issue) *FlowBoard {
151 q := b.Query
152 sortKey := flowSortKey(r.URL.Query().Get("sort"))
153 dir := flowDirKey(r.URL.Query().Get("dir"))
154 state := flowStateKey(r.URL.Query().Get("state"), false)
155 base := "/" + repo.FullPath() + "/-/issues"
156 people := map[string]flowPerson{}
157
158 var matched []store.Issue
159 openN, closedN := 0, 0
160 for _, iss := range all {
161 name, _ := s.flowAuthor(r, iss.Author, people)
162 bits := append(issueSearchBits(iss), name)
163 if !flowHit(q, bits...) {
164 continue
165 }
166 matched = append(matched, iss)
167 if iss.Status == "closed" {
168 closedN++
169 } else {
170 openN++
171 }
172 }
173 var shown []store.Issue
174 for _, iss := range matched {
175 if state == "all" || iss.Status == state || (state == "open" && iss.Status != "closed") {
176 shown = append(shown, iss)
177 }
178 }
179 sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {
180 return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number
181 })
182
183 rows := make([]FlowRow, 0, len(shown))
184 for _, iss := range shown {
185 name, href := s.flowAuthor(r, iss.Author, people)
186 var assigned []AccountLink
187 for _, who := range iss.Assignees {
188 n, href := s.flowAuthor(r, who, people)
189 if n == "" {
190 continue
191 }
192 assigned = append(assigned, AccountLink{Name: n, URL: href})
193 }
194 row := FlowRow{
195 Href: base + "/" + strconv.FormatInt(iss.Number, 10),
196 Title: iss.Title,
197 Ref: "#" + strconv.FormatInt(iss.Number, 10),
198 State: flowBadge(iss.Status),
199 StateLabel: s.flowStateLabel(r, iss.Status),
200 Created: s.ago(r, iss.CreatedAt),
201 Updated: s.ago(r, iss.UpdatedAt),
202 Author: name,
203 AuthorURL: href,
204 Confidential: iss.Confidential,
205 Labels: iss.Labels,
206 People: assigned,
207 Extra: iss.Milestone,
208 }
209 if row.State == "open" {
210 if notes, err := s.Store.ListIssueNotes(r.Context(), iss.ID); err == nil {
211 row.Comments = len(notes)
212 }
213 }
214 rows = append(rows, row)
215 }
216 return &FlowBoard{
217 Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,
218 FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), b.Label, b.Assignee),
219 CanNew: b.CanCreate,
220 NewHref: base + "/new",
221 NewKey: "issue.new",
222 EmptyKey: "issue.none",
223 Filters: true,
224 Label: b.Label,
225 Assignee: b.Assignee,
226 Labels: b.Labels,
227 People: b.People,
228 Rows: rows,
229 Tabs: []FlowTab{
230 {Href: flowHref(base, "open", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.open", Count: openN, On: state == "open"},
231 {Href: flowHref(base, "closed", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.closed", Count: closedN, On: state == "closed"},
232 {Href: flowHref(base, "all", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.all", Count: openN + closedN, On: state == "all"},
233 },
234 }
235}
236
237func (s *Server) attachFlowPipe(r *http.Request, repo store.Repo, mr store.MergeRequest, row *FlowRow) {
238 p, err := s.Store.LatestMergePipeline(r.Context(), repo.ID, mr.ID)
239 if err != nil {
240 return
241 }
242 jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)
243 st := displayStatus(p.Status, jobs)
244 row.PipeStatus = st
245 row.PipeLabel = s.tr(r, "pipe."+st)
246 row.PipeHref = "/" + repo.FullPath() + "/-/pipelines/" + strconv.FormatInt(p.ID, 10)
247}
248
249func (s *Server) flowAuthor(r *http.Request, username string, cache map[string]flowPerson) (string, string) {
250 username = strings.TrimSpace(username)
251 if username == "" {
252 return "", ""
253 }
254 if p, ok := cache[username]; ok {
255 return p.Name, p.URL
256 }
257 p := flowPerson{Name: username}
258 if u, err := s.Store.UserByUsername(r.Context(), username); err == nil && u.ID != 0 {
259 if name := strings.TrimSpace(u.DisplayName); name != "" {
260 p.Name = name
261 } else {
262 p.Name = u.Username
263 }
264 p.URL = "/users/" + u.Username
265 }
266 cache[username] = p
267 return p.Name, p.URL
268}
269
270func (s *Server) flowStateLabel(r *http.Request, status string) string {
271 switch status {
272 case "merged":
273 return s.tr(r, "list.merged")
274 case "closed":
275 return s.tr(r, "issue.closed")
276 default:
277 return s.tr(r, "issue.open")
278 }
279}
280
281func (s *Server) ago(r *http.Request, t time.Time) string {
282 if t.IsZero() {
283 return ""
284 }
285 return i18n.Ago(s.langOf(r), t.Unix())
286}
287
288func issueSearchBits(iss store.Issue) []string {
289 bits := []string{iss.Title, iss.Description, strconv.FormatInt(iss.Number, 10), "#" + strconv.FormatInt(iss.Number, 10), iss.Author, iss.Milestone}
290 bits = append(bits, iss.Assignees...)
291 for _, l := range iss.Labels {
292 bits = append(bits, l.Name)
293 }
294 return bits
295}
296
297func flowHit(q string, parts ...string) bool {
298 q = strings.ToLower(strings.TrimSpace(q))
299 if q == "" {
300 return true
301 }
302 q = strings.TrimPrefix(q, "!")
303 q = strings.TrimPrefix(q, "#")
304 for _, p := range parts {
305 if strings.Contains(strings.ToLower(p), q) {
306 return true
307 }
308 }
309 return false
310}
311
312func flowSortKey(raw string) string {
313 if raw == "updated" {
314 return "updated"
315 }
316 return "created"
317}
318
319func flowDirKey(raw string) string {
320 if raw == "asc" {
321 return "asc"
322 }
323 return "desc"
324}
325
326func flipDir(dir string) string {
327 if dir == "asc" {
328 return "desc"
329 }
330 return "asc"
331}
332
333func flowStateKey(raw string, merged bool) string {
334 switch raw {
335 case "closed", "all":
336 return raw
337 case "merged":
338 if merged {
339 return "merged"
340 }
341 }
342 return "open"
343}
344
345func flowBadge(status string) string {
346 switch status {
347 case "merged", "closed":
348 return status
349 default:
350 return "open"
351 }
352}
353
354func flowHref(base, state, q, sortKey, dir, label, assignee string) string {
355 v := url.Values{}
356 v.Set("state", state)
357 if strings.TrimSpace(q) != "" {
358 v.Set("q", q)
359 }
360 if sortKey == "updated" {
361 v.Set("sort", "updated")
362 }
363 if dir == "asc" {
364 v.Set("dir", "asc")
365 }
366 if label != "" {
367 v.Set("label", label)
368 }
369 if assignee != "" {
370 v.Set("assignee", assignee)
371 }
372 return base + "?" + v.Encode()
373}
374
375func sortFlow[T any](rows []T, sortKey, dir string, at func(i int) (created, updated time.Time, number int64)) {
376 sort.SliceStable(rows, func(i, j int) bool {
377 ac, au, an := at(i)
378 bc, bu, bn := at(j)
379 a, b := ac, bc
380 if sortKey == "updated" {
381 a, b = au, bu
382 }
383 if dir == "asc" {
384 if a.Equal(b) {
385 return an < bn
386 }
387 return a.Before(b)
388 }
389 if a.Equal(b) {
390 return an > bn
391 }
392 return a.After(b)
393 })
394}
internal/server/flow_list_test.go added +154 −0
@@ -0,0 +1,154 @@
1 package server
2
3 import (
4 "context"
5 "net/http"
6 "net/http/cookiejar"
7 "net/http/httptest"
8 "net/url"
9 "path/filepath"
10 "strings"
11 "testing"
12 "time"
13
14 "gitlab.com/Timfa/bluegit/internal/auth"
15 "gitlab.com/Timfa/bluegit/internal/config"
16 "gitlab.com/Timfa/bluegit/internal/store"
17 )
18
19 func TestFlowLists(t *testing.T) {
20 storage := t.TempDir()
21 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
22 if err != nil {
23 t.Fatal(err)
24 }
25 t.Cleanup(func() { _ = st.Close() })
26 cfg := config.Config{
27 BaseURL: "http://git.example", Listen: "127.0.0.1:0", StoragePath: storage,
28 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
29 Git: config.Git{Binary: "git", DefaultBranch: "master"},
30 }
31 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
32 ts := httptest.NewServer(srv.Handler())
33 t.Cleanup(ts.Close)
34 jar, _ := cookiejar.New(nil)
35 tim := &http.Client{Jar: jar}
36 page := read(t, mustGet(t, tim, ts.URL+"/login"))
37 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
38 "csrf": {csrfOf(t, page)}, "name": {"lijsten"}, "visibility": {"public"},
39 }))
40 ctx := context.Background()
41 repo, err := st.RepoByPath(ctx, "tim", "lijsten")
42 if err != nil {
43 t.Fatal(err)
44 }
45 user, err := st.UserByUsername(ctx, "tim")
46 if err != nil {
47 t.Fatal(err)
48 }
49 if err := st.SetProfile(ctx, user.ID, "Tim Falken", ""); err != nil {
50 t.Fatal(err)
51 }
52 openMR, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Alpha open", "tekst", "topic", "master")
53 if err != nil {
54 t.Fatal(err)
55 }
56 merged, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Beta samen", "", "ander", "master")
57 if err != nil {
58 t.Fatal(err)
59 }
60 closed, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Gamma dicht", "", "derde", "master")
61 if err != nil {
62 t.Fatal(err)
63 }
64 time.Sleep(1100 * time.Millisecond)
65 if err := st.SetMergeRequestStatus(ctx, merged.ID, "merged"); err != nil {
66 t.Fatal(err)
67 }
68 if err := st.SetMergeRequestStatus(ctx, closed.ID, "closed"); err != nil {
69 t.Fatal(err)
70 }
71 if _, err := st.AddNote(ctx, repo.ID, openMR.ID, user.ID, "een reactie"); err != nil {
72 t.Fatal(err)
73 }
74 pipeID, err := st.CreatePipeline(ctx, repo.ID, "abc", "refs/heads/topic", "push", "tim", "Alpha open", nil)
75 if err != nil {
76 t.Fatal(err)
77 }
78 if err := st.AttachPipelineMR(ctx, pipeID, openMR.ID); err != nil {
79 t.Fatal(err)
80 }
81
82 openPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests"))
83 for _, want := range []string{
84 `class="flowtabs"`, `class="on"`, `>Open <span class="flowcount">1</span>`,
85 `>Merged <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`,
86 `>All <span class="flowcount">3</span>`, `New merge request`, `/-/merge-requests/new`,
87 `<strong>Alpha open</strong>`, `!1`, `created`, `by <a href="/users/tim">Tim Falken</a>`,
88 `class="flowbadge open"`, `updated`, `class="flowtarget">master`,
89 `class="flowcomments"`, `aria-label="1 comment"`, `class="flowpipe status pending"`,
90 `name="sort"`, `Created date`, `Updated date`, `name="dir" value="desc"`,
91 } {
92 if !strings.Contains(openPage, want) {
93 t.Errorf("open lijst mist %s", want)
94 }
95 }
96 if strings.Contains(openPage, "Beta samen") || strings.Contains(openPage, "Gamma dicht") {
97 t.Fatalf("open lijst toont andere status\n%s", openPage)
98 }
99
100 mergedPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=merged"))
101 if !strings.Contains(mergedPage, `<strong>Beta samen</strong>`) || !strings.Contains(mergedPage, `class="flowbadge merged"`) || !strings.Contains(mergedPage, "!2") {
102 t.Fatalf("gemerged\n%s", mergedPage)
103 }
104 if strings.Contains(mergedPage, "flowtarget") || strings.Contains(mergedPage, "flowcomments") || strings.Contains(mergedPage, "flowpipe") {
105 t.Fatalf("gemergde rij hoort kaal te blijven\n%s", mergedPage)
106 }
107
108 found := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Gamma"))
109 if !strings.Contains(found, "Gamma dicht") || strings.Contains(found, "Alpha open") || !strings.Contains(found, `flowcount">1`) {
110 t.Fatalf("zoeken\n%s", found)
111 }
112 byName := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Falken"))
113 if !strings.Contains(byName, "Alpha open") || !strings.Contains(byName, `flowcount">3`) {
114 t.Fatalf("zoeken op naam\n%s", byName)
115 }
116
117 desc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated"))
118 if strings.Index(desc, "Beta samen") > strings.Index(desc, "Alpha open") {
119 t.Fatalf("bijgewerkt nieuwste eerst: Beta hoort vóór Alpha\n%s", desc)
120 }
121 asc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated&dir=asc"))
122 if !strings.Contains(asc, `name="dir" value="asc"`) || !strings.Contains(asc, `aria-label="Newest first"`) {
123 t.Fatalf("richting\n%s", asc)
124 }
125 if strings.Index(asc, "Beta samen") < strings.Index(asc, "Alpha open") {
126 t.Fatalf("bijgewerkt oudste eerst: Alpha hoort vóór Beta\n%s", asc)
127 }
128
129 openIss, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart open"})
130 if err != nil {
131 t.Fatal(err)
132 }
133 shut, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart dicht"})
134 if err != nil {
135 t.Fatal(err)
136 }
137 if _, err := st.SetIssueState(ctx, shut.ID, "closed"); err != nil {
138 t.Fatal(err)
139 }
140 _ = openIss
141 issues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues"))
142 for _, want := range []string{`>Open <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`, `>All <span class="flowcount">2</span>`, `<strong>Kaart open</strong>`, "#1", "New issue", `name="label"`, `name="assignee"`} {
143 if !strings.Contains(issues, want) {
144 t.Errorf("issues mist %s", want)
145 }
146 }
147 if strings.Contains(issues, "Kaart dicht") {
148 t.Fatalf("open issues toont gesloten\n%s", issues)
149 }
150 closedIssues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues?state=closed"))
151 if !strings.Contains(closedIssues, "Kaart dicht") || strings.Contains(closedIssues, "Kaart open") {
152 t.Fatalf("gesloten issues\n%s", closedIssues)
153 }
154 }
@@ -0,0 +1,154 @@
1package server
2
3import (
4 "context"
5 "net/http"
6 "net/http/cookiejar"
7 "net/http/httptest"
8 "net/url"
9 "path/filepath"
10 "strings"
11 "testing"
12 "time"
13
14 "gitlab.com/Timfa/bluegit/internal/auth"
15 "gitlab.com/Timfa/bluegit/internal/config"
16 "gitlab.com/Timfa/bluegit/internal/store"
17)
18
19func TestFlowLists(t *testing.T) {
20 storage := t.TempDir()
21 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
22 if err != nil {
23 t.Fatal(err)
24 }
25 t.Cleanup(func() { _ = st.Close() })
26 cfg := config.Config{
27 BaseURL: "http://git.example", Listen: "127.0.0.1:0", StoragePath: storage,
28 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
29 Git: config.Git{Binary: "git", DefaultBranch: "master"},
30 }
31 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
32 ts := httptest.NewServer(srv.Handler())
33 t.Cleanup(ts.Close)
34 jar, _ := cookiejar.New(nil)
35 tim := &http.Client{Jar: jar}
36 page := read(t, mustGet(t, tim, ts.URL+"/login"))
37 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
38 "csrf": {csrfOf(t, page)}, "name": {"lijsten"}, "visibility": {"public"},
39 }))
40 ctx := context.Background()
41 repo, err := st.RepoByPath(ctx, "tim", "lijsten")
42 if err != nil {
43 t.Fatal(err)
44 }
45 user, err := st.UserByUsername(ctx, "tim")
46 if err != nil {
47 t.Fatal(err)
48 }
49 if err := st.SetProfile(ctx, user.ID, "Tim Falken", ""); err != nil {
50 t.Fatal(err)
51 }
52 openMR, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Alpha open", "tekst", "topic", "master")
53 if err != nil {
54 t.Fatal(err)
55 }
56 merged, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Beta samen", "", "ander", "master")
57 if err != nil {
58 t.Fatal(err)
59 }
60 closed, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Gamma dicht", "", "derde", "master")
61 if err != nil {
62 t.Fatal(err)
63 }
64 time.Sleep(1100 * time.Millisecond)
65 if err := st.SetMergeRequestStatus(ctx, merged.ID, "merged"); err != nil {
66 t.Fatal(err)
67 }
68 if err := st.SetMergeRequestStatus(ctx, closed.ID, "closed"); err != nil {
69 t.Fatal(err)
70 }
71 if _, err := st.AddNote(ctx, repo.ID, openMR.ID, user.ID, "een reactie"); err != nil {
72 t.Fatal(err)
73 }
74 pipeID, err := st.CreatePipeline(ctx, repo.ID, "abc", "refs/heads/topic", "push", "tim", "Alpha open", nil)
75 if err != nil {
76 t.Fatal(err)
77 }
78 if err := st.AttachPipelineMR(ctx, pipeID, openMR.ID); err != nil {
79 t.Fatal(err)
80 }
81
82 openPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests"))
83 for _, want := range []string{
84 `class="flowtabs"`, `class="on"`, `>Open <span class="flowcount">1</span>`,
85 `>Merged <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`,
86 `>All <span class="flowcount">3</span>`, `New merge request`, `/-/merge-requests/new`,
87 `<strong>Alpha open</strong>`, `!1`, `created`, `by <a href="/users/tim">Tim Falken</a>`,
88 `class="flowbadge open"`, `updated`, `class="flowtarget">master`,
89 `class="flowcomments"`, `aria-label="1 comment"`, `class="flowpipe status pending"`,
90 `name="sort"`, `Created date`, `Updated date`, `name="dir" value="desc"`,
91 } {
92 if !strings.Contains(openPage, want) {
93 t.Errorf("open lijst mist %s", want)
94 }
95 }
96 if strings.Contains(openPage, "Beta samen") || strings.Contains(openPage, "Gamma dicht") {
97 t.Fatalf("open lijst toont andere status\n%s", openPage)
98 }
99
100 mergedPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=merged"))
101 if !strings.Contains(mergedPage, `<strong>Beta samen</strong>`) || !strings.Contains(mergedPage, `class="flowbadge merged"`) || !strings.Contains(mergedPage, "!2") {
102 t.Fatalf("gemerged\n%s", mergedPage)
103 }
104 if strings.Contains(mergedPage, "flowtarget") || strings.Contains(mergedPage, "flowcomments") || strings.Contains(mergedPage, "flowpipe") {
105 t.Fatalf("gemergde rij hoort kaal te blijven\n%s", mergedPage)
106 }
107
108 found := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Gamma"))
109 if !strings.Contains(found, "Gamma dicht") || strings.Contains(found, "Alpha open") || !strings.Contains(found, `flowcount">1`) {
110 t.Fatalf("zoeken\n%s", found)
111 }
112 byName := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Falken"))
113 if !strings.Contains(byName, "Alpha open") || !strings.Contains(byName, `flowcount">3`) {
114 t.Fatalf("zoeken op naam\n%s", byName)
115 }
116
117 desc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated"))
118 if strings.Index(desc, "Beta samen") > strings.Index(desc, "Alpha open") {
119 t.Fatalf("bijgewerkt nieuwste eerst: Beta hoort vóór Alpha\n%s", desc)
120 }
121 asc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated&dir=asc"))
122 if !strings.Contains(asc, `name="dir" value="asc"`) || !strings.Contains(asc, `aria-label="Newest first"`) {
123 t.Fatalf("richting\n%s", asc)
124 }
125 if strings.Index(asc, "Beta samen") < strings.Index(asc, "Alpha open") {
126 t.Fatalf("bijgewerkt oudste eerst: Alpha hoort vóór Beta\n%s", asc)
127 }
128
129 openIss, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart open"})
130 if err != nil {
131 t.Fatal(err)
132 }
133 shut, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart dicht"})
134 if err != nil {
135 t.Fatal(err)
136 }
137 if _, err := st.SetIssueState(ctx, shut.ID, "closed"); err != nil {
138 t.Fatal(err)
139 }
140 _ = openIss
141 issues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues"))
142 for _, want := range []string{`>Open <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`, `>All <span class="flowcount">2</span>`, `<strong>Kaart open</strong>`, "#1", "New issue", `name="label"`, `name="assignee"`} {
143 if !strings.Contains(issues, want) {
144 t.Errorf("issues mist %s", want)
145 }
146 }
147 if strings.Contains(issues, "Kaart dicht") {
148 t.Fatalf("open issues toont gesloten\n%s", issues)
149 }
150 closedIssues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues?state=closed"))
151 if !strings.Contains(closedIssues, "Kaart dicht") || strings.Contains(closedIssues, "Kaart open") {
152 t.Fatalf("gesloten issues\n%s", closedIssues)
153 }
154}
internal/server/issues.go +34 −11
@@ -48,9 +48,10 @@ type IssueBoard struct {
48 48
49 49 // IssueChoice is een label of persoon in een formulier.
50 50 type IssueChoice struct {
51 Name string
52 Color string
53 On bool
51 Name string
52 Color string
53 AvatarURL string
54 On bool
54 55 }
55 56
56 57 // IssueRow is één issue in een lijst of op de detailpagina.
@@ -65,6 +66,7 @@ type IssueRow struct {
65 66 Due string
66 67 When string
67 68 Assignees string
69 People []AccountLink
68 70 Labels []store.Label
69 71 HTML template.HTML
70 72 }
@@ -93,23 +95,26 @@ func (s *Server) issuesPage(w http.ResponseWriter, r *http.Request) {
93 95 v.Page = "issues"
94 96 v.Wide = true
95 97 b := s.issueBoard(r, repo, role, u)
96 state := r.URL.Query().Get("state")
97 if state != "closed" && state != "all" {
98 state = "open"
99 }
100 b.State = state
101 98 b.Query = strings.TrimSpace(r.URL.Query().Get("q"))
102 99 b.Label = strings.TrimSpace(r.URL.Query().Get("label"))
103 100 b.Assignee = strings.TrimSpace(r.URL.Query().Get("assignee"))
104 101 list, err := s.Store.ListIssues(r.Context(), repo.ID, store.IssueFilter{
105 State: b.State, Query: b.Query, Label: b.Label, Assignee: b.Assignee,
102 State: "all", Label: b.Label, Assignee: b.Assignee,
106 103 ViewerID: u.ID, Triage: role.CanTriageIssue(),
107 104 })
108 105 if err != nil {
109 106 s.fail(w, r, err)
110 107 return
111 108 }
109 v.Flow = s.flowIssues(r, repo, b, list)
110 b.State = v.Flow.State
112 111 for _, iss := range list {
112 if iss.Status != b.State && b.State != "all" {
113 continue
114 }
115 if !flowHit(b.Query, issueSearchBits(iss)...) {
116 continue
117 }
113 118 b.List = append(b.List, s.issueRow(r, repo, iss))
114 119 }
115 120 v.Issues = b
@@ -442,7 +447,7 @@ func (s *Server) issueBoard(r *http.Request, repo store.Repo, role access.Role,
442 447 b.Labels = append(b.Labels, IssueChoice{Name: l.Name, Color: l.Color})
443 448 }
444 449 for _, p := range s.issueCandidates(r.Context(), repo) {
445 b.People = append(b.People, IssueChoice{Name: p.Username})
450 b.People = append(b.People, IssueChoice{Name: p.Username, AvatarURL: p.AvatarURL})
446 451 }
447 452 return b
448 453 }
@@ -452,10 +457,28 @@ func (s *Server) issueRow(r *http.Request, repo store.Repo, iss store.Issue) Iss
452 457 if iss.Author != "" {
453 458 url = "/users/" + iss.Author
454 459 }
460 var people []AccountLink
461 for _, name := range iss.Assignees {
462 name = strings.TrimSpace(name)
463 if name == "" {
464 continue
465 }
466 link := AccountLink{Name: name}
467 if u, err := s.Store.UserByUsername(r.Context(), name); err == nil && u.ID != 0 {
468 if display := strings.TrimSpace(u.DisplayName); display != "" {
469 link.Name = display
470 } else {
471 link.Name = u.Username
472 }
473 link.URL = "/users/" + u.Username
474 }
475 people = append(people, link)
476 }
455 477 return IssueRow{
456 478 Number: iss.Number, Title: iss.Title, Status: iss.Status, Author: iss.Author, AuthorURL: url,
457 479 Confidential: iss.Confidential, Milestone: iss.Milestone, Due: iss.DueOn,
458 480 When: i18n.FormatDate(s.langOf(r), iss.CreatedAt), Assignees: strings.Join(iss.Assignees, ", "),
481 People: people,
459 482 Labels: iss.Labels, HTML: template.HTML(markdown.Render(iss.Description, "", "", "/"+repo.FullPath())),
460 483 }
461 484 }
@@ -507,7 +530,7 @@ func (s *Server) issueCandidates(ctx context.Context, repo store.Repo) []store.M
507 530 }
508 531 if repo.OwnerKind == "user" {
509 532 if u, err := s.Store.UserByID(ctx, repo.OwnerID); err == nil {
510 seen[u.Username] = store.Member{UserID: u.ID, Username: u.Username, Role: access.RoleMaintainer}
533 seen[u.Username] = store.Member{UserID: u.ID, Username: u.Username, AvatarURL: u.AvatarURL, Role: access.RoleMaintainer}
511 534 }
512 535 }
513 536 if members, err := s.Store.ListMembers(ctx, "repo", repo.ID); err == nil {
@@ -48,9 +48,10 @@ type IssueBoard struct {
48
48
49// IssueChoice is een label of persoon in een formulier.
49// IssueChoice is een label of persoon in een formulier.
50type IssueChoice struct {
50type IssueChoice struct {
51 Name string
51 Name string
52 Color string
52 Color string
53 On bool
53 AvatarURL string
54 On bool
54}
55}
55
56
56// IssueRow is één issue in een lijst of op de detailpagina.
57// IssueRow is één issue in een lijst of op de detailpagina.
@@ -65,6 +66,7 @@ type IssueRow struct {
65 Due string
66 Due string
66 When string
67 When string
67 Assignees string
68 Assignees string
69 People []AccountLink
68 Labels []store.Label
70 Labels []store.Label
69 HTML template.HTML
71 HTML template.HTML
70}
72}
@@ -93,23 +95,26 @@ func (s *Server) issuesPage(w http.ResponseWriter, r *http.Request) {
93 v.Page = "issues"
95 v.Page = "issues"
94 v.Wide = true
96 v.Wide = true
95 b := s.issueBoard(r, repo, role, u)
97 b := s.issueBoard(r, repo, role, u)
96 state := r.URL.Query().Get("state")
97 if state != "closed" && state != "all" {
98 state = "open"
99 }
100 b.State = state
101 b.Query = strings.TrimSpace(r.URL.Query().Get("q"))
98 b.Query = strings.TrimSpace(r.URL.Query().Get("q"))
102 b.Label = strings.TrimSpace(r.URL.Query().Get("label"))
99 b.Label = strings.TrimSpace(r.URL.Query().Get("label"))
103 b.Assignee = strings.TrimSpace(r.URL.Query().Get("assignee"))
100 b.Assignee = strings.TrimSpace(r.URL.Query().Get("assignee"))
104 list, err := s.Store.ListIssues(r.Context(), repo.ID, store.IssueFilter{
101 list, err := s.Store.ListIssues(r.Context(), repo.ID, store.IssueFilter{
105 State: b.State, Query: b.Query, Label: b.Label, Assignee: b.Assignee,
102 State: "all", Label: b.Label, Assignee: b.Assignee,
106 ViewerID: u.ID, Triage: role.CanTriageIssue(),
103 ViewerID: u.ID, Triage: role.CanTriageIssue(),
107 })
104 })
108 if err != nil {
105 if err != nil {
109 s.fail(w, r, err)
106 s.fail(w, r, err)
110 return
107 return
111 }
108 }
109 v.Flow = s.flowIssues(r, repo, b, list)
110 b.State = v.Flow.State
112 for _, iss := range list {
111 for _, iss := range list {
112 if iss.Status != b.State && b.State != "all" {
113 continue
114 }
115 if !flowHit(b.Query, issueSearchBits(iss)...) {
116 continue
117 }
113 b.List = append(b.List, s.issueRow(r, repo, iss))
118 b.List = append(b.List, s.issueRow(r, repo, iss))
114 }
119 }
115 v.Issues = b
120 v.Issues = b
@@ -442,7 +447,7 @@ func (s *Server) issueBoard(r *http.Request, repo store.Repo, role access.Role,
442 b.Labels = append(b.Labels, IssueChoice{Name: l.Name, Color: l.Color})
447 b.Labels = append(b.Labels, IssueChoice{Name: l.Name, Color: l.Color})
443 }
448 }
444 for _, p := range s.issueCandidates(r.Context(), repo) {
449 for _, p := range s.issueCandidates(r.Context(), repo) {
445 b.People = append(b.People, IssueChoice{Name: p.Username})
450 b.People = append(b.People, IssueChoice{Name: p.Username, AvatarURL: p.AvatarURL})
446 }
451 }
447 return b
452 return b
448}
453}
@@ -452,10 +457,28 @@ func (s *Server) issueRow(r *http.Request, repo store.Repo, iss store.Issue) Iss
452 if iss.Author != "" {
457 if iss.Author != "" {
453 url = "/users/" + iss.Author
458 url = "/users/" + iss.Author
454 }
459 }
460 var people []AccountLink
461 for _, name := range iss.Assignees {
462 name = strings.TrimSpace(name)
463 if name == "" {
464 continue
465 }
466 link := AccountLink{Name: name}
467 if u, err := s.Store.UserByUsername(r.Context(), name); err == nil && u.ID != 0 {
468 if display := strings.TrimSpace(u.DisplayName); display != "" {
469 link.Name = display
470 } else {
471 link.Name = u.Username
472 }
473 link.URL = "/users/" + u.Username
474 }
475 people = append(people, link)
476 }
455 return IssueRow{
477 return IssueRow{
456 Number: iss.Number, Title: iss.Title, Status: iss.Status, Author: iss.Author, AuthorURL: url,
478 Number: iss.Number, Title: iss.Title, Status: iss.Status, Author: iss.Author, AuthorURL: url,
457 Confidential: iss.Confidential, Milestone: iss.Milestone, Due: iss.DueOn,
479 Confidential: iss.Confidential, Milestone: iss.Milestone, Due: iss.DueOn,
458 When: i18n.FormatDate(s.langOf(r), iss.CreatedAt), Assignees: strings.Join(iss.Assignees, ", "),
480 When: i18n.FormatDate(s.langOf(r), iss.CreatedAt), Assignees: strings.Join(iss.Assignees, ", "),
481 People: people,
459 Labels: iss.Labels, HTML: template.HTML(markdown.Render(iss.Description, "", "", "/"+repo.FullPath())),
482 Labels: iss.Labels, HTML: template.HTML(markdown.Render(iss.Description, "", "", "/"+repo.FullPath())),
460 }
483 }
461}
484}
@@ -507,7 +530,7 @@ func (s *Server) issueCandidates(ctx context.Context, repo store.Repo) []store.M
507 }
530 }
508 if repo.OwnerKind == "user" {
531 if repo.OwnerKind == "user" {
509 if u, err := s.Store.UserByID(ctx, repo.OwnerID); err == nil {
532 if u, err := s.Store.UserByID(ctx, repo.OwnerID); err == nil {
510 seen[u.Username] = store.Member{UserID: u.ID, Username: u.Username, Role: access.RoleMaintainer}
533 seen[u.Username] = store.Member{UserID: u.ID, Username: u.Username, AvatarURL: u.AvatarURL, Role: access.RoleMaintainer}
511 }
534 }
512 }
535 }
513 if members, err := s.Store.ListMembers(ctx, "repo", repo.ID); err == nil {
536 if members, err := s.Store.ListMembers(ctx, "repo", repo.ID); err == nil {
internal/server/marks_test.go added +121 −0
@@ -0,0 +1,121 @@
1 package server
2
3 import (
4 "context"
5 "net/http"
6 "net/http/cookiejar"
7 "net/http/httptest"
8 "net/url"
9 "os/exec"
10 "path/filepath"
11 "strings"
12 "testing"
13
14 "gitlab.com/Timfa/bluegit/internal/auth"
15 "gitlab.com/Timfa/bluegit/internal/config"
16 "gitlab.com/Timfa/bluegit/internal/store"
17 )
18
19 func TestTileHueIsStable(t *testing.T) {
20 if tileHue("BlueGit") != tileHue("bluegit") {
21 t.Fatal("hoofdletters horen dezelfde kleur te geven")
22 }
23 if tileHue("BlueGit") == tileHue("Storage") {
24 t.Fatal("twee verschillende namen horen uit elkaar te lopen")
25 }
26 for _, name := range []string{"", "a", "Blue Star", "timfa/bluegit"} {
27 hue := tileHue(name)
28 if len(hue) != 4 || hue[0:3] != "hue" || hue[3] < '0' || hue[3] > '7' {
29 t.Fatalf("kleur %q voor %q", hue, name)
30 }
31 }
32 }
33
34 func TestDashboardMarksAndCrumbs(t *testing.T) {
35 if _, err := exec.LookPath("git"); err != nil {
36 t.Skip("git ontbreekt")
37 }
38 storage := t.TempDir()
39 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
40 if err != nil {
41 t.Fatal(err)
42 }
43 t.Cleanup(func() { _ = st.Close() })
44 cfg := config.Config{
45 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
46 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
47 Git: config.Git{Binary: "git", DefaultBranch: "master"},
48 }
49 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
50 ts := httptest.NewServer(srv.Handler())
51 t.Cleanup(ts.Close)
52 jar, _ := cookiejar.New(nil)
53 tim := &http.Client{Jar: jar}
54 page := read(t, mustGet(t, tim, ts.URL+"/login"))
55 if _, err := st.UpsertUser(context.Background(), 1, "tim", "https://auth.timfalken.com/avatar/tim", false); err != nil {
56 t.Fatal(err)
57 }
58 page = read(t, mustPost(t, tim, ts.URL+"/new/group", url.Values{
59 "csrf": {csrfOf(t, page)}, "name": {"Blue Star"}, "description": {"sterren"},
60 }))
61 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
62 "csrf": {csrfOf(t, page)}, "name": {"demo"}, "description": {"eerste"}, "visibility": {"public"}, "group": {""},
63 }))
64 repo, err := st.RepoByPath(context.Background(), "tim", "demo")
65 if err != nil {
66 t.Fatal(err)
67 }
68 if err := st.SetLogoMIME(context.Background(), "repo", repo.ID, "image/png"); err != nil {
69 t.Fatal(err)
70 }
71
72 dash := read(t, mustGet(t, tim, ts.URL+"/"))
73 if strings.Contains(dash, `<p class="crumbs"`) {
74 t.Fatalf("dashboard herhaalt de titel in een broodkruimel:\n%s", dash)
75 }
76 if !strings.Contains(dash, "<h1>Overview</h1>") {
77 t.Fatal("dashboard mist de kop")
78 }
79 for _, want := range []string{
80 `class="tile" src="/tim/demo/-/logo"`,
81 `class="tile ` + tileHue("Blue Star") + `"`,
82 `href="/groups/blue-star"`,
83 ">B<",
84 } {
85 if !strings.Contains(dash, want) {
86 t.Fatalf("dashboard mist %q\n%s", want, dash)
87 }
88 }
89
90 account := read(t, mustGet(t, tim, ts.URL+"/settings"))
91 if !strings.Contains(account, `<p class="crumbs"><a href="/">Overview</a></p>`) || !strings.Contains(account, "<h1>Account</h1>") {
92 t.Fatalf("account-kruimel:\n%s", account)
93 }
94 if strings.Contains(account, `<p class="crumbs"><span>Overview</span>`) || strings.Contains(account, "<h1>Overview</h1>") {
95 t.Fatal("account herhaalt Overview als titel")
96 }
97
98 overview := read(t, mustGet(t, tim, ts.URL+"/tim/demo"))
99 if !strings.Contains(overview, `<p class="crumbs">`) || !strings.Contains(overview, `href="/users/tim"`) || !strings.Contains(overview, ">demo</a>") {
100 t.Fatalf("repo-kruimel hoort owner/naam te blijven:\n%s", overview)
101 }
102 if !strings.Contains(overview, "<h1>Overview</h1>") || !strings.Contains(overview, `class="tile" src="/tim/demo/-/logo"`) {
103 t.Fatalf("repo-overzicht:\n%s", overview)
104 }
105
106 members := read(t, mustGet(t, tim, ts.URL+"/groups/blue-star?tab=members"))
107 if !strings.Contains(members, `src="https://auth.timfalken.com/avatar/tim"`) || !strings.Contains(members, ">tim</a>") {
108 t.Fatalf("groepsleden:\n%s", members)
109 }
110 repoMembers := read(t, mustPost(t, tim, ts.URL+"/tim/demo/-/members", url.Values{
111 "csrf": {csrfOf(t, read(t, mustGet(t, tim, ts.URL+"/tim/demo/-/settings?tab=members")))}, "username": {"tim"}, "role": {"developer"},
112 }))
113 if !strings.Contains(repoMembers, `src="https://auth.timfalken.com/avatar/tim"`) {
114 t.Fatalf("repoleden:\n%s", repoMembers)
115 }
116
117 fresh := read(t, mustGet(t, tim, ts.URL+"/new"))
118 if !strings.Contains(fresh, `name="group"`) || !strings.Contains(fresh, `value="blue-star"`) || !strings.Contains(fresh, `class="tile `+tileHue("Blue Star")+`"`) {
119 t.Fatalf("kiezer:\n%s", fresh)
120 }
121 }
@@ -0,0 +1,121 @@
1package server
2
3import (
4 "context"
5 "net/http"
6 "net/http/cookiejar"
7 "net/http/httptest"
8 "net/url"
9 "os/exec"
10 "path/filepath"
11 "strings"
12 "testing"
13
14 "gitlab.com/Timfa/bluegit/internal/auth"
15 "gitlab.com/Timfa/bluegit/internal/config"
16 "gitlab.com/Timfa/bluegit/internal/store"
17)
18
19func TestTileHueIsStable(t *testing.T) {
20 if tileHue("BlueGit") != tileHue("bluegit") {
21 t.Fatal("hoofdletters horen dezelfde kleur te geven")
22 }
23 if tileHue("BlueGit") == tileHue("Storage") {
24 t.Fatal("twee verschillende namen horen uit elkaar te lopen")
25 }
26 for _, name := range []string{"", "a", "Blue Star", "timfa/bluegit"} {
27 hue := tileHue(name)
28 if len(hue) != 4 || hue[0:3] != "hue" || hue[3] < '0' || hue[3] > '7' {
29 t.Fatalf("kleur %q voor %q", hue, name)
30 }
31 }
32}
33
34func TestDashboardMarksAndCrumbs(t *testing.T) {
35 if _, err := exec.LookPath("git"); err != nil {
36 t.Skip("git ontbreekt")
37 }
38 storage := t.TempDir()
39 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
40 if err != nil {
41 t.Fatal(err)
42 }
43 t.Cleanup(func() { _ = st.Close() })
44 cfg := config.Config{
45 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
46 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
47 Git: config.Git{Binary: "git", DefaultBranch: "master"},
48 }
49 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
50 ts := httptest.NewServer(srv.Handler())
51 t.Cleanup(ts.Close)
52 jar, _ := cookiejar.New(nil)
53 tim := &http.Client{Jar: jar}
54 page := read(t, mustGet(t, tim, ts.URL+"/login"))
55 if _, err := st.UpsertUser(context.Background(), 1, "tim", "https://auth.timfalken.com/avatar/tim", false); err != nil {
56 t.Fatal(err)
57 }
58 page = read(t, mustPost(t, tim, ts.URL+"/new/group", url.Values{
59 "csrf": {csrfOf(t, page)}, "name": {"Blue Star"}, "description": {"sterren"},
60 }))
61 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
62 "csrf": {csrfOf(t, page)}, "name": {"demo"}, "description": {"eerste"}, "visibility": {"public"}, "group": {""},
63 }))
64 repo, err := st.RepoByPath(context.Background(), "tim", "demo")
65 if err != nil {
66 t.Fatal(err)
67 }
68 if err := st.SetLogoMIME(context.Background(), "repo", repo.ID, "image/png"); err != nil {
69 t.Fatal(err)
70 }
71
72 dash := read(t, mustGet(t, tim, ts.URL+"/"))
73 if strings.Contains(dash, `<p class="crumbs"`) {
74 t.Fatalf("dashboard herhaalt de titel in een broodkruimel:\n%s", dash)
75 }
76 if !strings.Contains(dash, "<h1>Overview</h1>") {
77 t.Fatal("dashboard mist de kop")
78 }
79 for _, want := range []string{
80 `class="tile" src="/tim/demo/-/logo"`,
81 `class="tile ` + tileHue("Blue Star") + `"`,
82 `href="/groups/blue-star"`,
83 ">B<",
84 } {
85 if !strings.Contains(dash, want) {
86 t.Fatalf("dashboard mist %q\n%s", want, dash)
87 }
88 }
89
90 account := read(t, mustGet(t, tim, ts.URL+"/settings"))
91 if !strings.Contains(account, `<p class="crumbs"><a href="/">Overview</a></p>`) || !strings.Contains(account, "<h1>Account</h1>") {
92 t.Fatalf("account-kruimel:\n%s", account)
93 }
94 if strings.Contains(account, `<p class="crumbs"><span>Overview</span>`) || strings.Contains(account, "<h1>Overview</h1>") {
95 t.Fatal("account herhaalt Overview als titel")
96 }
97
98 overview := read(t, mustGet(t, tim, ts.URL+"/tim/demo"))
99 if !strings.Contains(overview, `<p class="crumbs">`) || !strings.Contains(overview, `href="/users/tim"`) || !strings.Contains(overview, ">demo</a>") {
100 t.Fatalf("repo-kruimel hoort owner/naam te blijven:\n%s", overview)
101 }
102 if !strings.Contains(overview, "<h1>Overview</h1>") || !strings.Contains(overview, `class="tile" src="/tim/demo/-/logo"`) {
103 t.Fatalf("repo-overzicht:\n%s", overview)
104 }
105
106 members := read(t, mustGet(t, tim, ts.URL+"/groups/blue-star?tab=members"))
107 if !strings.Contains(members, `src="https://auth.timfalken.com/avatar/tim"`) || !strings.Contains(members, ">tim</a>") {
108 t.Fatalf("groepsleden:\n%s", members)
109 }
110 repoMembers := read(t, mustPost(t, tim, ts.URL+"/tim/demo/-/members", url.Values{
111 "csrf": {csrfOf(t, read(t, mustGet(t, tim, ts.URL+"/tim/demo/-/settings?tab=members")))}, "username": {"tim"}, "role": {"developer"},
112 }))
113 if !strings.Contains(repoMembers, `src="https://auth.timfalken.com/avatar/tim"`) {
114 t.Fatalf("repoleden:\n%s", repoMembers)
115 }
116
117 fresh := read(t, mustGet(t, tim, ts.URL+"/new"))
118 if !strings.Contains(fresh, `name="group"`) || !strings.Contains(fresh, `value="blue-star"`) || !strings.Contains(fresh, `class="tile `+tileHue("Blue Star")+`"`) {
119 t.Fatalf("kiezer:\n%s", fresh)
120 }
121}
internal/server/mr_layout_test.go added +115 −0
@@ -0,0 +1,115 @@
1 package server
2
3 import (
4 "net/http"
5 "net/http/cookiejar"
6 "net/http/httptest"
7 "net/url"
8 "os/exec"
9 "path/filepath"
10 "regexp"
11 "strings"
12 "testing"
13
14 "gitlab.com/Timfa/bluegit/internal/auth"
15 "gitlab.com/Timfa/bluegit/internal/config"
16 "gitlab.com/Timfa/bluegit/internal/store"
17 )
18
19 func TestMRPageLayout(t *testing.T) {
20 if _, err := exec.LookPath("git"); err != nil {
21 t.Skip("git ontbreekt")
22 }
23 storage := t.TempDir()
24 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
25 if err != nil {
26 t.Fatal(err)
27 }
28 t.Cleanup(func() { _ = st.Close() })
29 cfg := config.Config{
30 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
31 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
32 Git: config.Git{Binary: "git", DefaultBranch: "master"},
33 }
34 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
35 ts := httptest.NewServer(srv.Handler())
36 t.Cleanup(ts.Close)
37 jar, _ := cookiejar.New(nil)
38 tim := &http.Client{Jar: jar}
39 page := read(t, mustGet(t, tim, ts.URL+"/login"))
40 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
41 "csrf": {csrfOf(t, page)}, "name": {"layout"}, "visibility": {"public"},
42 }))
43 page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{
44 "csrf": {csrfOf(t, page)}, "name": {"laptop"},
45 }))
46 token := between(page, `<p class="code">`, "</p>")
47 remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/layout.git"
48 work := t.TempDir()
49 git(t, work, "init", "-b", "master")
50 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
51 git(t, work, "config", "user.name", "tim")
52 git(t, work, "config", "commit.gpgsign", "false")
53 writeFile(t, filepath.Join(work, "hello.txt"), "alpha\n")
54 git(t, work, "add", "hello.txt")
55 git(t, work, "commit", "-m", "start")
56 git(t, work, "remote", "add", "origin", remote)
57 git(t, work, "push", "-u", "origin", "master")
58 git(t, work, "checkout", "-b", "topic")
59 writeFile(t, filepath.Join(work, "a.txt"), "een\n")
60 git(t, work, "add", "a.txt")
61 git(t, work, "commit", "-m", "eerste")
62 writeFile(t, filepath.Join(work, "b.txt"), "twee\n")
63 git(t, work, "add", "b.txt")
64 git(t, work, "commit", "-m", "tweede")
65 writeFile(t, filepath.Join(work, "a.txt"), "drie\n")
66 git(t, work, "add", "a.txt")
67 git(t, work, "commit", "-m", "derde")
68 git(t, work, "push", "-u", "origin", "topic")
69
70 page = read(t, mustPost(t, tim, ts.URL+"/tim/layout/-/merge-requests", url.Values{
71 "csrf": {csrfOf(t, page)}, "title": {"Layout van de pagina"}, "description": {"tekst"},
72 "source": {"topic"}, "target": {"master"},
73 }))
74 for _, want := range []string{
75 `class="mrstate open"`, ">Open<", "wants to merge", "3 commits",
76 `data-copy="topic"`, `data-copy="master"`,
77 `Commits <span class="count">3</span>`,
78 `Changes <span class="count">2</span>`,
79 `Pipelines <span class="count">0</span>`,
80 "Delete source branch", "> Squash",
81 "created just now", `href="/users/tim"`, `class="avatar sm">T</span>`,
82 "mrwidget",
83 } {
84 if !strings.Contains(page, want) {
85 t.Fatalf("open MR mist %q:\n%s", want, page)
86 }
87 }
88
89 page = read(t, mustPost(t, tim, ts.URL+"/tim/layout/-/merge-requests/1/merge", url.Values{
90 "csrf": {csrfOf(t, page)},
91 }))
92 git(t, work, "fetch", "origin", "master")
93 shaBytes, err := exec.Command("git", "-C", work, "rev-parse", "origin/master").Output()
94 if err != nil {
95 t.Fatal(err)
96 }
97 sha := strings.TrimSpace(string(shaBytes))
98 short := sha
99 if len(short) > 8 {
100 short = short[:8]
101 }
102 for _, want := range []string{
103 `class="mrstate merged"`, ">Merged<", "Merged by", `href="/users/tim"`,
104 "merged just now", `<code>` + short + `</code>`, `data-copy="` + sha + `"`,
105 `Commits <span class="count">3</span>`,
106 `Changes <span class="count">2</span>`,
107 } {
108 if !strings.Contains(page, want) {
109 t.Fatalf("gemergede MR mist %q:\n%s", want, page)
110 }
111 }
112 if regexp.MustCompile(`(?s)pushlist">` + sha).MatchString(page) {
113 t.Fatalf("de sha hoort niet als ruwe tijdlijntekst:\n%s", page)
114 }
115 }
@@ -0,0 +1,115 @@
1package server
2
3import (
4 "net/http"
5 "net/http/cookiejar"
6 "net/http/httptest"
7 "net/url"
8 "os/exec"
9 "path/filepath"
10 "regexp"
11 "strings"
12 "testing"
13
14 "gitlab.com/Timfa/bluegit/internal/auth"
15 "gitlab.com/Timfa/bluegit/internal/config"
16 "gitlab.com/Timfa/bluegit/internal/store"
17)
18
19func TestMRPageLayout(t *testing.T) {
20 if _, err := exec.LookPath("git"); err != nil {
21 t.Skip("git ontbreekt")
22 }
23 storage := t.TempDir()
24 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
25 if err != nil {
26 t.Fatal(err)
27 }
28 t.Cleanup(func() { _ = st.Close() })
29 cfg := config.Config{
30 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
31 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
32 Git: config.Git{Binary: "git", DefaultBranch: "master"},
33 }
34 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
35 ts := httptest.NewServer(srv.Handler())
36 t.Cleanup(ts.Close)
37 jar, _ := cookiejar.New(nil)
38 tim := &http.Client{Jar: jar}
39 page := read(t, mustGet(t, tim, ts.URL+"/login"))
40 page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
41 "csrf": {csrfOf(t, page)}, "name": {"layout"}, "visibility": {"public"},
42 }))
43 page = read(t, mustPost(t, tim, ts.URL+"/settings/tokens", url.Values{
44 "csrf": {csrfOf(t, page)}, "name": {"laptop"},
45 }))
46 token := between(page, `<p class="code">`, "</p>")
47 remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/layout.git"
48 work := t.TempDir()
49 git(t, work, "init", "-b", "master")
50 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
51 git(t, work, "config", "user.name", "tim")
52 git(t, work, "config", "commit.gpgsign", "false")
53 writeFile(t, filepath.Join(work, "hello.txt"), "alpha\n")
54 git(t, work, "add", "hello.txt")
55 git(t, work, "commit", "-m", "start")
56 git(t, work, "remote", "add", "origin", remote)
57 git(t, work, "push", "-u", "origin", "master")
58 git(t, work, "checkout", "-b", "topic")
59 writeFile(t, filepath.Join(work, "a.txt"), "een\n")
60 git(t, work, "add", "a.txt")
61 git(t, work, "commit", "-m", "eerste")
62 writeFile(t, filepath.Join(work, "b.txt"), "twee\n")
63 git(t, work, "add", "b.txt")
64 git(t, work, "commit", "-m", "tweede")
65 writeFile(t, filepath.Join(work, "a.txt"), "drie\n")
66 git(t, work, "add", "a.txt")
67 git(t, work, "commit", "-m", "derde")
68 git(t, work, "push", "-u", "origin", "topic")
69
70 page = read(t, mustPost(t, tim, ts.URL+"/tim/layout/-/merge-requests", url.Values{
71 "csrf": {csrfOf(t, page)}, "title": {"Layout van de pagina"}, "description": {"tekst"},
72 "source": {"topic"}, "target": {"master"},
73 }))
74 for _, want := range []string{
75 `class="mrstate open"`, ">Open<", "wants to merge", "3 commits",
76 `data-copy="topic"`, `data-copy="master"`,
77 `Commits <span class="count">3</span>`,
78 `Changes <span class="count">2</span>`,
79 `Pipelines <span class="count">0</span>`,
80 "Delete source branch", "> Squash",
81 "created just now", `href="/users/tim"`, `class="avatar sm">T</span>`,
82 "mrwidget",
83 } {
84 if !strings.Contains(page, want) {
85 t.Fatalf("open MR mist %q:\n%s", want, page)
86 }
87 }
88
89 page = read(t, mustPost(t, tim, ts.URL+"/tim/layout/-/merge-requests/1/merge", url.Values{
90 "csrf": {csrfOf(t, page)},
91 }))
92 git(t, work, "fetch", "origin", "master")
93 shaBytes, err := exec.Command("git", "-C", work, "rev-parse", "origin/master").Output()
94 if err != nil {
95 t.Fatal(err)
96 }
97 sha := strings.TrimSpace(string(shaBytes))
98 short := sha
99 if len(short) > 8 {
100 short = short[:8]
101 }
102 for _, want := range []string{
103 `class="mrstate merged"`, ">Merged<", "Merged by", `href="/users/tim"`,
104 "merged just now", `<code>` + short + `</code>`, `data-copy="` + sha + `"`,
105 `Commits <span class="count">3</span>`,
106 `Changes <span class="count">2</span>`,
107 } {
108 if !strings.Contains(page, want) {
109 t.Fatalf("gemergede MR mist %q:\n%s", want, page)
110 }
111 }
112 if regexp.MustCompile(`(?s)pushlist">` + sha).MatchString(page) {
113 t.Fatalf("de sha hoort niet als ruwe tijdlijntekst:\n%s", page)
114 }
115}
internal/server/mr_page.go +171 −1
@@ -7,6 +7,7 @@ import (
7 7 "sort"
8 8 "strconv"
9 9 "strings"
10 "time"
10 11
11 12 "gitlab.com/Timfa/bluegit/internal/access"
12 13 "gitlab.com/Timfa/bluegit/internal/gitrepo"
@@ -115,6 +116,7 @@ func (s *Server) finishMR(r *http.Request, v *View, repo store.Repo, mr store.Me
115 116 })
116 117 v.Notes = stampNotes(v.CommitDiff, rows)
117 118 s.fillTimeline(r, v, repo, mr, rows)
119 s.fillMRBanner(r, v, repo, mr)
118 120 }
119 121
120 122 func (s *Server) fillBranchChoices(r *http.Request, v *View, repo store.Repo) {
@@ -175,8 +177,12 @@ func (s *Server) fillTimeline(r *http.Request, v *View, repo store.Repo, mr stor
175 177 continue
176 178 }
177 179 actor, actorURL := who(e.Actor)
180 body := e.Body
181 if e.Kind == "merged" && shaLike(strings.TrimSpace(body)) {
182 body = ""
183 }
178 184 items = append(items, TimelineItem{
179 Kind: e.Kind, Actor: actor, ActorURL: actorURL, Text: s.tr(r, key), Body: e.Body,
185 Kind: e.Kind, Actor: actor, ActorURL: actorURL, Text: s.tr(r, key), Body: body,
180 186 When: i18n.FormatDate(lang, e.CreatedAt), At: e.CreatedAt, Rank: 2,
181 187 })
182 188 }
@@ -318,3 +324,167 @@ func (s *Server) recordMRPushes(repo store.Repo, user store.User, branch, before
318 324 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "pushed", body)
319 325 }
320 326 }
327
328 // MRBanner is the header and the counts on a merge request.
329 type MRBanner struct {
330 State, StateLabel string
331 WhenLabel string
332 Author, AuthorURL, Avatar string
333 Initial string
334 CommitPhrase string
335 NCommits, NPipes, NChanges int
336 MergedBy, MergedByURL string
337 MergedDate string
338 MergeSHA, MergeShort string
339 }
340
341 func (s *Server) fillMRBanner(r *http.Request, v *View, repo store.Repo, mr store.MergeRequest) {
342 lang := s.langOf(r)
343 state := mr.Status
344 if state == "" {
345 state = "open"
346 }
347 label := s.tr(r, "mr.state."+state)
348 if label == "mr.state."+state {
349 label = state
350 }
351 b := &MRBanner{State: state, StateLabel: label}
352 when := mr.CreatedAt
353 whenKey := "mr.when.created"
354 var merger string
355 var mergeAt time.Time
356 var mergeSHA string
357 events, _ := s.Store.ListMREvents(r.Context(), mr.ID)
358 for _, e := range events {
359 if e.Kind != "merged" {
360 continue
361 }
362 merger = e.Actor
363 mergeAt = e.CreatedAt
364 if shaLike(strings.TrimSpace(e.Body)) {
365 mergeSHA = strings.TrimSpace(e.Body)
366 }
367 }
368 switch state {
369 case "merged":
370 whenKey = "mr.when.merged"
371 if !mergeAt.IsZero() {
372 when = mergeAt
373 } else if !mr.UpdatedAt.IsZero() {
374 when = mr.UpdatedAt
375 }
376 b.MergedDate = i18n.FormatDate(lang, when)
377 if merger != "" {
378 b.MergedBy = merger
379 if u, err := s.Store.UserByUsername(r.Context(), merger); err == nil && u.ID != 0 {
380 b.MergedBy = u.Username
381 b.MergedByURL = "/users/" + u.Username
382 }
383 }
384 if mergeSHA == "" {
385 mergeSHA = s.mergeCommitSHA(r.Context(), repo, mr)
386 }
387 if shaLike(mergeSHA) {
388 b.MergeSHA = mergeSHA
389 b.MergeShort = mergeSHA
390 if len(mergeSHA) > 8 {
391 b.MergeShort = mergeSHA[:8]
392 }
393 }
394 case "closed":
395 whenKey = "mr.when.closed"
396 if !mr.UpdatedAt.IsZero() {
397 when = mr.UpdatedAt
398 }
399 }
400 b.WhenLabel = s.tr(r, whenKey, i18n.Ago(lang, when.Unix()))
401 if mr.Author != "" {
402 b.Author = mr.Author
403 b.Initial = initialOf(mr.Author)
404 if u, err := s.Store.UserByUsername(r.Context(), mr.Author); err == nil && u.ID != 0 {
405 b.Author = u.Username
406 b.AuthorURL = "/users/" + u.Username
407 b.Avatar = u.AvatarURL
408 b.Initial = initialOf(u.Username)
409 }
410 }
411 n := s.commitCount(r.Context(), repo, mr.TargetBranch, mr.SourceBranch)
412 if state == "merged" && shaLike(mergeSHA) && (n == 0 || len(v.Commits) == 0 || v.CommitDiff == nil || len(v.CommitDiff.Files) == 0) {
413 if brought := s.fillFromMergeCommit(r, v, repo, mergeSHA); n == 0 && brought > 0 {
414 n = brought
415 }
416 }
417 b.NCommits = n
418 if n == 1 {
419 b.CommitPhrase = s.tr(r, "count.commit.one", n)
420 } else {
421 b.CommitPhrase = s.tr(r, "count.commit.many", n)
422 }
423 b.NPipes = len(v.PipeRows)
424 if v.CommitDiff != nil {
425 b.NChanges = len(v.CommitDiff.Files)
426 }
427 v.Banner = b
428 }
429
430 func (s *Server) commitCount(ctx context.Context, repo store.Repo, from, to string) int {
431 if s.Git == "" || s.StoragePath() == "" || from == "" || to == "" || from == to {
432 return 0
433 }
434 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
435 n, err := strconv.Atoi(gitOne(ctx, s.Git, dir, "rev-list", "--count", from+".."+to))
436 if err != nil || n < 0 {
437 return 0
438 }
439 return n
440 }
441
442 // fillFromMergeCommit vult commits en diff vanuit de merge-commit als de bronbranch
443 // al in het doel zit of inmiddels weg is. Het aantal is wat die commit binnenbracht.
444 func (s *Server) fillFromMergeCommit(r *http.Request, v *View, repo store.Repo, sha string) int {
445 if s.Git == "" || s.StoragePath() == "" {
446 return 0
447 }
448 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
449 parents := strings.Fields(gitOne(r.Context(), s.Git, dir, "rev-list", "--parents", "-n", "1", sha))
450 if len(parents) < 3 {
451 return 0
452 }
453 base, tip := parents[1], parents[2]
454 n, err := strconv.Atoi(gitOne(r.Context(), s.Git, dir, "rev-list", "--count", base+".."+tip))
455 if err != nil || n < 0 {
456 n = 0
457 }
458 if len(v.Commits) == 0 {
459 if commits, err := gitrepo.Log(r.Context(), s.Git, dir, base+".."+tip, 50); err == nil && len(commits) > 0 {
460 v.Commits = s.presentCommits(r.Context(), repo.ID, commits, s.langOf(r))
461 }
462 }
463 if v.CommitDiff == nil || len(v.CommitDiff.Files) == 0 {
464 if files, err := gitrepo.ComparePatch(r.Context(), s.Git, dir, base, tip); err == nil && len(files) > 0 {
465 v.CommitDiff = presentCommitDiff(repo.FullPath(), tip, nil, files)
466 }
467 }
468 return n
469 }
470
471 func (s *Server) mergeCommitSHA(ctx context.Context, repo store.Repo, mr store.MergeRequest) string {
472 if s.Git == "" || s.StoragePath() == "" || mr.SourceBranch == "" || mr.TargetBranch == "" {
473 return ""
474 }
475 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
476 needle := "Merge branch '" + mr.SourceBranch + "'"
477 return gitOne(ctx, s.Git, dir, "log", "-1", "--format=%H", "-F", "--grep="+needle, "refs/heads/"+mr.TargetBranch)
478 }
479
480 func shaLike(s string) bool {
481 if len(s) < 7 || len(s) > 40 {
482 return false
483 }
484 for _, c := range s {
485 if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
486 return false
487 }
488 }
489 return true
490 }
@@ -7,6 +7,7 @@ import (
7 "sort"
7 "sort"
8 "strconv"
8 "strconv"
9 "strings"
9 "strings"
10 "time"
10
11
11 "gitlab.com/Timfa/bluegit/internal/access"
12 "gitlab.com/Timfa/bluegit/internal/access"
12 "gitlab.com/Timfa/bluegit/internal/gitrepo"
13 "gitlab.com/Timfa/bluegit/internal/gitrepo"
@@ -115,6 +116,7 @@ func (s *Server) finishMR(r *http.Request, v *View, repo store.Repo, mr store.Me
115 })
116 })
116 v.Notes = stampNotes(v.CommitDiff, rows)
117 v.Notes = stampNotes(v.CommitDiff, rows)
117 s.fillTimeline(r, v, repo, mr, rows)
118 s.fillTimeline(r, v, repo, mr, rows)
119 s.fillMRBanner(r, v, repo, mr)
118}
120}
119
121
120func (s *Server) fillBranchChoices(r *http.Request, v *View, repo store.Repo) {
122func (s *Server) fillBranchChoices(r *http.Request, v *View, repo store.Repo) {
@@ -175,8 +177,12 @@ func (s *Server) fillTimeline(r *http.Request, v *View, repo store.Repo, mr stor
175 continue
177 continue
176 }
178 }
177 actor, actorURL := who(e.Actor)
179 actor, actorURL := who(e.Actor)
180 body := e.Body
181 if e.Kind == "merged" && shaLike(strings.TrimSpace(body)) {
182 body = ""
183 }
178 items = append(items, TimelineItem{
184 items = append(items, TimelineItem{
179 Kind: e.Kind, Actor: actor, ActorURL: actorURL, Text: s.tr(r, key), Body: e.Body,
185 Kind: e.Kind, Actor: actor, ActorURL: actorURL, Text: s.tr(r, key), Body: body,
180 When: i18n.FormatDate(lang, e.CreatedAt), At: e.CreatedAt, Rank: 2,
186 When: i18n.FormatDate(lang, e.CreatedAt), At: e.CreatedAt, Rank: 2,
181 })
187 })
182 }
188 }
@@ -318,3 +324,167 @@ func (s *Server) recordMRPushes(repo store.Repo, user store.User, branch, before
318 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "pushed", body)
324 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "pushed", body)
319 }
325 }
320}
326}
327
328// MRBanner is the header and the counts on a merge request.
329type MRBanner struct {
330 State, StateLabel string
331 WhenLabel string
332 Author, AuthorURL, Avatar string
333 Initial string
334 CommitPhrase string
335 NCommits, NPipes, NChanges int
336 MergedBy, MergedByURL string
337 MergedDate string
338 MergeSHA, MergeShort string
339}
340
341func (s *Server) fillMRBanner(r *http.Request, v *View, repo store.Repo, mr store.MergeRequest) {
342 lang := s.langOf(r)
343 state := mr.Status
344 if state == "" {
345 state = "open"
346 }
347 label := s.tr(r, "mr.state."+state)
348 if label == "mr.state."+state {
349 label = state
350 }
351 b := &MRBanner{State: state, StateLabel: label}
352 when := mr.CreatedAt
353 whenKey := "mr.when.created"
354 var merger string
355 var mergeAt time.Time
356 var mergeSHA string
357 events, _ := s.Store.ListMREvents(r.Context(), mr.ID)
358 for _, e := range events {
359 if e.Kind != "merged" {
360 continue
361 }
362 merger = e.Actor
363 mergeAt = e.CreatedAt
364 if shaLike(strings.TrimSpace(e.Body)) {
365 mergeSHA = strings.TrimSpace(e.Body)
366 }
367 }
368 switch state {
369 case "merged":
370 whenKey = "mr.when.merged"
371 if !mergeAt.IsZero() {
372 when = mergeAt
373 } else if !mr.UpdatedAt.IsZero() {
374 when = mr.UpdatedAt
375 }
376 b.MergedDate = i18n.FormatDate(lang, when)
377 if merger != "" {
378 b.MergedBy = merger
379 if u, err := s.Store.UserByUsername(r.Context(), merger); err == nil && u.ID != 0 {
380 b.MergedBy = u.Username
381 b.MergedByURL = "/users/" + u.Username
382 }
383 }
384 if mergeSHA == "" {
385 mergeSHA = s.mergeCommitSHA(r.Context(), repo, mr)
386 }
387 if shaLike(mergeSHA) {
388 b.MergeSHA = mergeSHA
389 b.MergeShort = mergeSHA
390 if len(mergeSHA) > 8 {
391 b.MergeShort = mergeSHA[:8]
392 }
393 }
394 case "closed":
395 whenKey = "mr.when.closed"
396 if !mr.UpdatedAt.IsZero() {
397 when = mr.UpdatedAt
398 }
399 }
400 b.WhenLabel = s.tr(r, whenKey, i18n.Ago(lang, when.Unix()))
401 if mr.Author != "" {
402 b.Author = mr.Author
403 b.Initial = initialOf(mr.Author)
404 if u, err := s.Store.UserByUsername(r.Context(), mr.Author); err == nil && u.ID != 0 {
405 b.Author = u.Username
406 b.AuthorURL = "/users/" + u.Username
407 b.Avatar = u.AvatarURL
408 b.Initial = initialOf(u.Username)
409 }
410 }
411 n := s.commitCount(r.Context(), repo, mr.TargetBranch, mr.SourceBranch)
412 if state == "merged" && shaLike(mergeSHA) && (n == 0 || len(v.Commits) == 0 || v.CommitDiff == nil || len(v.CommitDiff.Files) == 0) {
413 if brought := s.fillFromMergeCommit(r, v, repo, mergeSHA); n == 0 && brought > 0 {
414 n = brought
415 }
416 }
417 b.NCommits = n
418 if n == 1 {
419 b.CommitPhrase = s.tr(r, "count.commit.one", n)
420 } else {
421 b.CommitPhrase = s.tr(r, "count.commit.many", n)
422 }
423 b.NPipes = len(v.PipeRows)
424 if v.CommitDiff != nil {
425 b.NChanges = len(v.CommitDiff.Files)
426 }
427 v.Banner = b
428}
429
430func (s *Server) commitCount(ctx context.Context, repo store.Repo, from, to string) int {
431 if s.Git == "" || s.StoragePath() == "" || from == "" || to == "" || from == to {
432 return 0
433 }
434 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
435 n, err := strconv.Atoi(gitOne(ctx, s.Git, dir, "rev-list", "--count", from+".."+to))
436 if err != nil || n < 0 {
437 return 0
438 }
439 return n
440}
441
442// fillFromMergeCommit vult commits en diff vanuit de merge-commit als de bronbranch
443// al in het doel zit of inmiddels weg is. Het aantal is wat die commit binnenbracht.
444func (s *Server) fillFromMergeCommit(r *http.Request, v *View, repo store.Repo, sha string) int {
445 if s.Git == "" || s.StoragePath() == "" {
446 return 0
447 }
448 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
449 parents := strings.Fields(gitOne(r.Context(), s.Git, dir, "rev-list", "--parents", "-n", "1", sha))
450 if len(parents) < 3 {
451 return 0
452 }
453 base, tip := parents[1], parents[2]
454 n, err := strconv.Atoi(gitOne(r.Context(), s.Git, dir, "rev-list", "--count", base+".."+tip))
455 if err != nil || n < 0 {
456 n = 0
457 }
458 if len(v.Commits) == 0 {
459 if commits, err := gitrepo.Log(r.Context(), s.Git, dir, base+".."+tip, 50); err == nil && len(commits) > 0 {
460 v.Commits = s.presentCommits(r.Context(), repo.ID, commits, s.langOf(r))
461 }
462 }
463 if v.CommitDiff == nil || len(v.CommitDiff.Files) == 0 {
464 if files, err := gitrepo.ComparePatch(r.Context(), s.Git, dir, base, tip); err == nil && len(files) > 0 {
465 v.CommitDiff = presentCommitDiff(repo.FullPath(), tip, nil, files)
466 }
467 }
468 return n
469}
470
471func (s *Server) mergeCommitSHA(ctx context.Context, repo store.Repo, mr store.MergeRequest) string {
472 if s.Git == "" || s.StoragePath() == "" || mr.SourceBranch == "" || mr.TargetBranch == "" {
473 return ""
474 }
475 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
476 needle := "Merge branch '" + mr.SourceBranch + "'"
477 return gitOne(ctx, s.Git, dir, "log", "-1", "--format=%H", "-F", "--grep="+needle, "refs/heads/"+mr.TargetBranch)
478}
479
480func shaLike(s string) bool {
481 if len(s) < 7 || len(s) > 40 {
482 return false
483 }
484 for _, c := range s {
485 if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
486 return false
487 }
488 }
489 return true
490}
internal/server/ops_ci.go +36 −0
@@ -101,6 +101,42 @@ func (s *Server) opJobAction(ctx context.Context, user store.User, repo store.Re
101 101 return job, nil
102 102 }
103 103
104 func (s *Server) opRetryPipeline(ctx context.Context, user store.User, repo store.Repo, pipeID int64, mode string) (int64, error) {
105 role, err := s.repoRole(ctx, user, repo)
106 if err != nil {
107 return 0, err
108 }
109 if !role.CanWriteCode() {
110 return 0, fail(403, i18n.E("err.forbidden"))
111 }
112 p, err := s.Store.PipelineByID(ctx, repo.ID, pipeID)
113 if err != nil {
114 return 0, notFound(err)
115 }
116 switch mode {
117 case "all":
118 id, err := s.Store.ClonePipeline(ctx, repo.ID, p.ID)
119 if err != nil {
120 if store.IsNotFound(err) {
121 return 0, notFound(err)
122 }
123 return 0, fail(400, err)
124 }
125 return id, nil
126 case "failed":
127 ok, err := s.Store.RetryFailedJobs(ctx, p.ID)
128 if err != nil {
129 return 0, fail(400, err)
130 }
131 if !ok {
132 return 0, fail(409, i18n.E("err.pipeNoFailed"))
133 }
134 return p.ID, nil
135 default:
136 return 0, fail(400, i18n.E("err.pipeRetryMode"))
137 }
138 }
139
104 140 func (s *Server) opCancelPipeline(ctx context.Context, user store.User, repo store.Repo, pipeID int64) error {
105 141 role, err := s.repoRole(ctx, user, repo)
106 142 if err != nil {
@@ -101,6 +101,42 @@ func (s *Server) opJobAction(ctx context.Context, user store.User, repo store.Re
101 return job, nil
101 return job, nil
102}
102}
103
103
104func (s *Server) opRetryPipeline(ctx context.Context, user store.User, repo store.Repo, pipeID int64, mode string) (int64, error) {
105 role, err := s.repoRole(ctx, user, repo)
106 if err != nil {
107 return 0, err
108 }
109 if !role.CanWriteCode() {
110 return 0, fail(403, i18n.E("err.forbidden"))
111 }
112 p, err := s.Store.PipelineByID(ctx, repo.ID, pipeID)
113 if err != nil {
114 return 0, notFound(err)
115 }
116 switch mode {
117 case "all":
118 id, err := s.Store.ClonePipeline(ctx, repo.ID, p.ID)
119 if err != nil {
120 if store.IsNotFound(err) {
121 return 0, notFound(err)
122 }
123 return 0, fail(400, err)
124 }
125 return id, nil
126 case "failed":
127 ok, err := s.Store.RetryFailedJobs(ctx, p.ID)
128 if err != nil {
129 return 0, fail(400, err)
130 }
131 if !ok {
132 return 0, fail(409, i18n.E("err.pipeNoFailed"))
133 }
134 return p.ID, nil
135 default:
136 return 0, fail(400, i18n.E("err.pipeRetryMode"))
137 }
138}
139
104func (s *Server) opCancelPipeline(ctx context.Context, user store.User, repo store.Repo, pipeID int64) error {
140func (s *Server) opCancelPipeline(ctx context.Context, user store.User, repo store.Repo, pipeID int64) error {
105 role, err := s.repoRole(ctx, user, repo)
141 role, err := s.repoRole(ctx, user, repo)
106 if err != nil {
142 if err != nil {
internal/server/ops_mr.go +6 −1
@@ -344,7 +344,12 @@ func (s *Server) opMergeMR(r *http.Request, user store.User, repo store.Repo, nu
344 344 fresh, ferr := s.Store.MergeRequestByNumber(ctx, repo.ID, mr.Number)
345 345 if ferr != nil || fresh.Status != "merged" {
346 346 _ = s.Store.SetMergeRequestStatus(ctx, mr.ID, "merged")
347 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", "")
347 sha := gitOne(ctx, s.Git, dir, "rev-parse", "--verify", "refs/heads/"+mr.TargetBranch)
348 body := ""
349 if shaLike(sha) {
350 body = sha
351 }
352 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", body)
348 353 mr.Status = "merged"
349 354 s.mrHook(repo, mr, user.Username, "merged", "")
350 355 s.closeIssueNumbers(ctx, repo, user, closingNumbers(texts...))
@@ -344,7 +344,12 @@ func (s *Server) opMergeMR(r *http.Request, user store.User, repo store.Repo, nu
344 fresh, ferr := s.Store.MergeRequestByNumber(ctx, repo.ID, mr.Number)
344 fresh, ferr := s.Store.MergeRequestByNumber(ctx, repo.ID, mr.Number)
345 if ferr != nil || fresh.Status != "merged" {
345 if ferr != nil || fresh.Status != "merged" {
346 _ = s.Store.SetMergeRequestStatus(ctx, mr.ID, "merged")
346 _ = s.Store.SetMergeRequestStatus(ctx, mr.ID, "merged")
347 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", "")
347 sha := gitOne(ctx, s.Git, dir, "rev-parse", "--verify", "refs/heads/"+mr.TargetBranch)
348 body := ""
349 if shaLike(sha) {
350 body = sha
351 }
352 _ = s.Store.AddMREvent(ctx, repo.ID, mr.ID, user.ID, "merged", body)
348 mr.Status = "merged"
353 mr.Status = "merged"
349 s.mrHook(repo, mr, user.Username, "merged", "")
354 s.mrHook(repo, mr, user.Username, "merged", "")
350 s.closeIssueNumbers(ctx, repo, user, closingNumbers(texts...))
355 s.closeIssueNumbers(ctx, repo, user, closingNumbers(texts...))
internal/server/people.go +40 −3
@@ -8,9 +8,28 @@ import (
8 8
9 9 "gitlab.com/Timfa/bluegit/internal/gitrepo"
10 10 "gitlab.com/Timfa/bluegit/internal/i18n"
11 "gitlab.com/Timfa/bluegit/internal/names"
11 12 "gitlab.com/Timfa/bluegit/internal/store"
12 13 )
13 14
15 // userShort stuurt /<username> door naar /users/<username>.
16 // Het eerste paddeel is de gedeelde namespace van gebruikers en groepen
17 // (repositories staan op /<owner>/<repo>, groepen op /groups/<pad>).
18 // Vaste routes zoals /login blijven specifieker. Alleen een bestaande
19 // gebruiker krijgt een redirect; een groepsnaam of onbekende naam niet.
20 func (s *Server) userShort(w http.ResponseWriter, r *http.Request) {
21 name := strings.ToLower(strings.TrimSpace(r.PathValue("name")))
22 if names.ValidUsername(name) != nil {
23 http.NotFound(w, r)
24 return
25 }
26 if _, err := s.Store.UserByUsername(r.Context(), name); err != nil {
27 http.NotFound(w, r)
28 return
29 }
30 http.Redirect(w, r, "/users/"+name, http.StatusFound)
31 }
32
14 33 func (s *Server) profile(w http.ResponseWriter, r *http.Request) {
15 34 name := strings.ToLower(strings.TrimSpace(r.PathValue("username")))
16 35 u, err := s.Store.UserByUsername(r.Context(), name)
@@ -133,10 +152,15 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P
133 152 }
134 153 if u, ok := s.userForEmail(ctx, c.Email, cache, miss); ok {
135 154 row.Author = u.Username
136 row.UserURL = "/users/" + u.Username
155 row.Who = strings.TrimSpace(u.DisplayName)
156 if row.Who == "" {
157 row.Who = u.Username
158 }
159 row.WhoURL = "/users/" + u.Username
160 row.UserURL = row.WhoURL
137 161 row.Avatar = u.AvatarURL
138 162 row.Initial = initialOf(u.Username)
139 return row
163 return finishCommit(row, c.Email, c.Author)
140 164 }
141 165 if pusher.UserID != 0 && pusher.Username != "" {
142 166 row.Author = pusher.Username
@@ -149,7 +173,7 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P
149 173 row.PushedBy = pusher.Username
150 174 }
151 175 }
152 return row
176 return finishCommit(row, c.Email, c.Author)
153 177 }
154 178
155 179 func (s *Server) userForEmail(ctx context.Context, email string, cache map[string]store.User, miss map[string]bool) (store.User, bool) {
@@ -172,6 +196,19 @@ func (s *Server) userForEmail(ctx context.Context, email string, cache map[strin
172 196 return u, true
173 197 }
174 198
199 // tileHue kiest een vaste kleurklasse bij een naam, zodat dezelfde
200 // repo of groep steeds hetzelfde vierkantje krijgt.
201 func tileHue(name string) string {
202 n := 0
203 for _, r := range strings.ToLower(strings.TrimSpace(name)) {
204 n = n*33 + int(r)
205 }
206 if n < 0 {
207 n = -n
208 }
209 return "hue" + string(rune('0'+(n%8)))
210 }
211
175 212 func initialOf(s string) string {
176 213 s = strings.TrimSpace(s)
177 214 if s == "" {
@@ -8,9 +8,28 @@ import (
8
8
9 "gitlab.com/Timfa/bluegit/internal/gitrepo"
9 "gitlab.com/Timfa/bluegit/internal/gitrepo"
10 "gitlab.com/Timfa/bluegit/internal/i18n"
10 "gitlab.com/Timfa/bluegit/internal/i18n"
11 "gitlab.com/Timfa/bluegit/internal/names"
11 "gitlab.com/Timfa/bluegit/internal/store"
12 "gitlab.com/Timfa/bluegit/internal/store"
12)
13)
13
14
15// userShort stuurt /<username> door naar /users/<username>.
16// Het eerste paddeel is de gedeelde namespace van gebruikers en groepen
17// (repositories staan op /<owner>/<repo>, groepen op /groups/<pad>).
18// Vaste routes zoals /login blijven specifieker. Alleen een bestaande
19// gebruiker krijgt een redirect; een groepsnaam of onbekende naam niet.
20func (s *Server) userShort(w http.ResponseWriter, r *http.Request) {
21 name := strings.ToLower(strings.TrimSpace(r.PathValue("name")))
22 if names.ValidUsername(name) != nil {
23 http.NotFound(w, r)
24 return
25 }
26 if _, err := s.Store.UserByUsername(r.Context(), name); err != nil {
27 http.NotFound(w, r)
28 return
29 }
30 http.Redirect(w, r, "/users/"+name, http.StatusFound)
31}
32
14func (s *Server) profile(w http.ResponseWriter, r *http.Request) {
33func (s *Server) profile(w http.ResponseWriter, r *http.Request) {
15 name := strings.ToLower(strings.TrimSpace(r.PathValue("username")))
34 name := strings.ToLower(strings.TrimSpace(r.PathValue("username")))
16 u, err := s.Store.UserByUsername(r.Context(), name)
35 u, err := s.Store.UserByUsername(r.Context(), name)
@@ -133,10 +152,15 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P
133 }
152 }
134 if u, ok := s.userForEmail(ctx, c.Email, cache, miss); ok {
153 if u, ok := s.userForEmail(ctx, c.Email, cache, miss); ok {
135 row.Author = u.Username
154 row.Author = u.Username
136 row.UserURL = "/users/" + u.Username
155 row.Who = strings.TrimSpace(u.DisplayName)
156 if row.Who == "" {
157 row.Who = u.Username
158 }
159 row.WhoURL = "/users/" + u.Username
160 row.UserURL = row.WhoURL
137 row.Avatar = u.AvatarURL
161 row.Avatar = u.AvatarURL
138 row.Initial = initialOf(u.Username)
162 row.Initial = initialOf(u.Username)
139 return row
163 return finishCommit(row, c.Email, c.Author)
140 }
164 }
141 if pusher.UserID != 0 && pusher.Username != "" {
165 if pusher.UserID != 0 && pusher.Username != "" {
142 row.Author = pusher.Username
166 row.Author = pusher.Username
@@ -149,7 +173,7 @@ func (s *Server) oneCommit(ctx context.Context, c gitrepo.Commit, pusher store.P
149 row.PushedBy = pusher.Username
173 row.PushedBy = pusher.Username
150 }
174 }
151 }
175 }
152 return row
176 return finishCommit(row, c.Email, c.Author)
153}
177}
154
178
155func (s *Server) userForEmail(ctx context.Context, email string, cache map[string]store.User, miss map[string]bool) (store.User, bool) {
179func (s *Server) userForEmail(ctx context.Context, email string, cache map[string]store.User, miss map[string]bool) (store.User, bool) {
@@ -172,6 +196,19 @@ func (s *Server) userForEmail(ctx context.Context, email string, cache map[strin
172 return u, true
196 return u, true
173}
197}
174
198
199// tileHue kiest een vaste kleurklasse bij een naam, zodat dezelfde
200// repo of groep steeds hetzelfde vierkantje krijgt.
201func tileHue(name string) string {
202 n := 0
203 for _, r := range strings.ToLower(strings.TrimSpace(name)) {
204 n = n*33 + int(r)
205 }
206 if n < 0 {
207 n = -n
208 }
209 return "hue" + string(rune('0'+(n%8)))
210}
211
175func initialOf(s string) string {
212func initialOf(s string) string {
176 s = strings.TrimSpace(s)
213 s = strings.TrimSpace(s)
177 if s == "" {
214 if s == "" {
internal/server/pipeline_page.go +52 −1
@@ -35,6 +35,8 @@ type PipeRow struct {
35 35 Avatar string
36 36 Initial string
37 37 Stages []StageView
38 Failed bool
39 Live bool
38 40 }
39 41
40 42 // StageView is één bolletje in de stages-kolom.
@@ -160,14 +162,26 @@ func (s *Server) pipeRow(r *http.Request, lang i18n.Lang, repo store.Repo, p sto
160 162 initial = strings.ToUpper(actor[:1])
161 163 }
162 164 sourceLabel, mrNumber := s.pipelineSourceLabel(r, repo, p)
163 return PipeRow{
165 row := PipeRow{
164 166 ID: p.ID, Status: status, Label: s.tr(r, "pipe."+status),
165 167 Duration: pipelineClock(p), When: i18n.Ago(lang, p.CreatedAt.Unix()),
166 168 Title: p.CommitTitle, SHA: p.CommitSHA, Short: shortSHA(p.CommitSHA),
167 169 Ref: name, RefKind: kind, Source: p.Source, SourceLabel: sourceLabel, MRNumber: mrNumber,
168 170 Actor: actor, ActorURL: actorURL, Avatar: avatar, Initial: initial,
169 171 Stages: stageViews(jobs, ranks, func(key string, args ...any) string { return s.tr(r, key, args...) }),
172 Failed: jobsFailed(jobs),
170 173 }
174 row.Live = rowLive(row)
175 return row
176 }
177
178 func jobsFailed(jobs []store.Job) bool {
179 for _, j := range jobs {
180 if j.Status == "failed" {
181 return true
182 }
183 }
184 return false
171 185 }
172 186
173 187 // pipelineSourceLabel benoemt een pipeline die bij een merge request hoort,
@@ -447,6 +461,43 @@ func (s *Server) jobLog(w http.ResponseWriter, r *http.Request) {
447 461 })
448 462 }
449 463
464 func (s *Server) retryPipeline(w http.ResponseWriter, r *http.Request) {
465 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
466 if !ok || !s.csrfOK(w, r) {
467 return
468 }
469 id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
470 if err != nil {
471 http.NotFound(w, r)
472 return
473 }
474 back := safeRepoBack(repo, r.FormValue("back"))
475 if back == "" {
476 back = repoURL(repo) + "/-/pipelines/" + strconv.FormatInt(id, 10)
477 }
478 newID, err := s.opRetryPipeline(r.Context(), u, repo, id, r.FormValue("mode"))
479 if !s.uiOK(w, r, back, err) {
480 return
481 }
482 dest := back
483 if r.FormValue("mode") == "all" {
484 dest = repoURL(repo) + "/-/pipelines/" + strconv.FormatInt(newID, 10)
485 }
486 s.redirect(w, r, dest, s.tr(r, "flash.pipeRetry"), "")
487 }
488
489 func safeRepoBack(repo store.Repo, back string) string {
490 back = strings.TrimSpace(back)
491 prefix := "/" + repo.FullPath()
492 if back != prefix && !strings.HasPrefix(back, prefix+"/") {
493 return ""
494 }
495 if strings.Contains(back, "..") || strings.Contains(back, "\\") || strings.Contains(back, "\n") || strings.Contains(back, "?") {
496 return ""
497 }
498 return back
499 }
500
450 501 func (s *Server) playJob(w http.ResponseWriter, r *http.Request) {
451 502 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
452 503 if !ok || !s.csrfOK(w, r) {
@@ -35,6 +35,8 @@ type PipeRow struct {
35 Avatar string
35 Avatar string
36 Initial string
36 Initial string
37 Stages []StageView
37 Stages []StageView
38 Failed bool
39 Live bool
38}
40}
39
41
40// StageView is één bolletje in de stages-kolom.
42// StageView is één bolletje in de stages-kolom.
@@ -160,14 +162,26 @@ func (s *Server) pipeRow(r *http.Request, lang i18n.Lang, repo store.Repo, p sto
160 initial = strings.ToUpper(actor[:1])
162 initial = strings.ToUpper(actor[:1])
161 }
163 }
162 sourceLabel, mrNumber := s.pipelineSourceLabel(r, repo, p)
164 sourceLabel, mrNumber := s.pipelineSourceLabel(r, repo, p)
163 return PipeRow{
165 row := PipeRow{
164 ID: p.ID, Status: status, Label: s.tr(r, "pipe."+status),
166 ID: p.ID, Status: status, Label: s.tr(r, "pipe."+status),
165 Duration: pipelineClock(p), When: i18n.Ago(lang, p.CreatedAt.Unix()),
167 Duration: pipelineClock(p), When: i18n.Ago(lang, p.CreatedAt.Unix()),
166 Title: p.CommitTitle, SHA: p.CommitSHA, Short: shortSHA(p.CommitSHA),
168 Title: p.CommitTitle, SHA: p.CommitSHA, Short: shortSHA(p.CommitSHA),
167 Ref: name, RefKind: kind, Source: p.Source, SourceLabel: sourceLabel, MRNumber: mrNumber,
169 Ref: name, RefKind: kind, Source: p.Source, SourceLabel: sourceLabel, MRNumber: mrNumber,
168 Actor: actor, ActorURL: actorURL, Avatar: avatar, Initial: initial,
170 Actor: actor, ActorURL: actorURL, Avatar: avatar, Initial: initial,
169 Stages: stageViews(jobs, ranks, func(key string, args ...any) string { return s.tr(r, key, args...) }),
171 Stages: stageViews(jobs, ranks, func(key string, args ...any) string { return s.tr(r, key, args...) }),
172 Failed: jobsFailed(jobs),
170 }
173 }
174 row.Live = rowLive(row)
175 return row
176}
177
178func jobsFailed(jobs []store.Job) bool {
179 for _, j := range jobs {
180 if j.Status == "failed" {
181 return true
182 }
183 }
184 return false
171}
185}
172
186
173// pipelineSourceLabel benoemt een pipeline die bij een merge request hoort,
187// pipelineSourceLabel benoemt een pipeline die bij een merge request hoort,
@@ -447,6 +461,43 @@ func (s *Server) jobLog(w http.ResponseWriter, r *http.Request) {
447 })
461 })
448}
462}
449
463
464func (s *Server) retryPipeline(w http.ResponseWriter, r *http.Request) {
465 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
466 if !ok || !s.csrfOK(w, r) {
467 return
468 }
469 id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
470 if err != nil {
471 http.NotFound(w, r)
472 return
473 }
474 back := safeRepoBack(repo, r.FormValue("back"))
475 if back == "" {
476 back = repoURL(repo) + "/-/pipelines/" + strconv.FormatInt(id, 10)
477 }
478 newID, err := s.opRetryPipeline(r.Context(), u, repo, id, r.FormValue("mode"))
479 if !s.uiOK(w, r, back, err) {
480 return
481 }
482 dest := back
483 if r.FormValue("mode") == "all" {
484 dest = repoURL(repo) + "/-/pipelines/" + strconv.FormatInt(newID, 10)
485 }
486 s.redirect(w, r, dest, s.tr(r, "flash.pipeRetry"), "")
487}
488
489func safeRepoBack(repo store.Repo, back string) string {
490 back = strings.TrimSpace(back)
491 prefix := "/" + repo.FullPath()
492 if back != prefix && !strings.HasPrefix(back, prefix+"/") {
493 return ""
494 }
495 if strings.Contains(back, "..") || strings.Contains(back, "\\") || strings.Contains(back, "\n") || strings.Contains(back, "?") {
496 return ""
497 }
498 return back
499}
500
450func (s *Server) playJob(w http.ResponseWriter, r *http.Request) {
501func (s *Server) playJob(w http.ResponseWriter, r *http.Request) {
451 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
502 u, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
452 if !ok || !s.csrfOK(w, r) {
503 if !ok || !s.csrfOK(w, r) {
internal/server/pipeline_page_test.go +26 −0
@@ -7,6 +7,7 @@ import (
7 7 "net/http/cookiejar"
8 8 "net/http/httptest"
9 9 "net/url"
10 "os"
10 11 "path/filepath"
11 12 "strconv"
12 13 "strings"
@@ -35,6 +36,27 @@ func TestParseLogSections(t *testing.T) {
35 36 }
36 37 }
37 38
39 func TestJobStageFilterStays(t *testing.T) {
40 css, err := os.ReadFile("static/style.css")
41 if err != nil {
42 t.Fatal(err)
43 }
44 if !strings.Contains(string(css), ".related li[hidden] { display: none !important; }") {
45 t.Fatal("display:flex op .related li wint van het hidden-attribuut")
46 }
47 js, err := os.ReadFile("static/pipeline.js")
48 if err != nil {
49 t.Fatal(err)
50 }
51 src := string(js)
52 if !strings.Contains(src, "applyStage(stageSelect.value)") {
53 t.Fatal("de live-poll moet de gekozen stage opnieuw toepassen")
54 }
55 if strings.Contains(src, "stageSelect.value =") {
56 t.Fatal("de poll mag de gekozen stage niet overschrijven")
57 }
58 }
59
38 60 func TestPipelinePages(t *testing.T) {
39 61 storage := t.TempDir()
40 62 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
@@ -181,12 +203,16 @@ func TestPipelinePages(t *testing.T) {
181 203 `class="ansi-bold ansi-fg-red"`, ">rood<",
182 204 "Running on Steve", "Log timestamps in UTC.", "Related jobs", ">Steve<", "Push",
183 205 `data-stage="deploy" hidden`, `value="test" selected`,
206 `data-stage-select`, `/assets/pipeline.js`,
184 207 "for", "v0.0.26",
185 208 } {
186 209 if !strings.Contains(jobPage, want) {
187 210 t.Errorf("jobpagina mist %q", want)
188 211 }
189 212 }
213 if strings.Contains(jobPage, `data-stage="test" hidden`) {
214 t.Fatal("de stage van de huidige job hoort zichtbaar te zijn")
215 }
190 216
191 217 res, err = client.Get(jobURL + "/log?raw=1")
192 218 if err != nil {
@@ -7,6 +7,7 @@ import (
7 "net/http/cookiejar"
7 "net/http/cookiejar"
8 "net/http/httptest"
8 "net/http/httptest"
9 "net/url"
9 "net/url"
10 "os"
10 "path/filepath"
11 "path/filepath"
11 "strconv"
12 "strconv"
12 "strings"
13 "strings"
@@ -35,6 +36,27 @@ func TestParseLogSections(t *testing.T) {
35 }
36 }
36}
37}
37
38
39func TestJobStageFilterStays(t *testing.T) {
40 css, err := os.ReadFile("static/style.css")
41 if err != nil {
42 t.Fatal(err)
43 }
44 if !strings.Contains(string(css), ".related li[hidden] { display: none !important; }") {
45 t.Fatal("display:flex op .related li wint van het hidden-attribuut")
46 }
47 js, err := os.ReadFile("static/pipeline.js")
48 if err != nil {
49 t.Fatal(err)
50 }
51 src := string(js)
52 if !strings.Contains(src, "applyStage(stageSelect.value)") {
53 t.Fatal("de live-poll moet de gekozen stage opnieuw toepassen")
54 }
55 if strings.Contains(src, "stageSelect.value =") {
56 t.Fatal("de poll mag de gekozen stage niet overschrijven")
57 }
58}
59
38func TestPipelinePages(t *testing.T) {
60func TestPipelinePages(t *testing.T) {
39 storage := t.TempDir()
61 storage := t.TempDir()
40 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
62 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
@@ -181,12 +203,16 @@ func TestPipelinePages(t *testing.T) {
181 `class="ansi-bold ansi-fg-red"`, ">rood<",
203 `class="ansi-bold ansi-fg-red"`, ">rood<",
182 "Running on Steve", "Log timestamps in UTC.", "Related jobs", ">Steve<", "Push",
204 "Running on Steve", "Log timestamps in UTC.", "Related jobs", ">Steve<", "Push",
183 `data-stage="deploy" hidden`, `value="test" selected`,
205 `data-stage="deploy" hidden`, `value="test" selected`,
206 `data-stage-select`, `/assets/pipeline.js`,
184 "for", "v0.0.26",
207 "for", "v0.0.26",
185 } {
208 } {
186 if !strings.Contains(jobPage, want) {
209 if !strings.Contains(jobPage, want) {
187 t.Errorf("jobpagina mist %q", want)
210 t.Errorf("jobpagina mist %q", want)
188 }
211 }
189 }
212 }
213 if strings.Contains(jobPage, `data-stage="test" hidden`) {
214 t.Fatal("de stage van de huidige job hoort zichtbaar te zijn")
215 }
190
216
191 res, err = client.Get(jobURL + "/log?raw=1")
217 res, err = client.Get(jobURL + "/log?raw=1")
192 if err != nil {
218 if err != nil {
internal/server/pipeline_retry_test.go added +256 −0
@@ -0,0 +1,256 @@
1 package server
2
3 import (
4 "context"
5 "encoding/json"
6 "io"
7 "net/http"
8 "net/http/cookiejar"
9 "net/http/httptest"
10 "net/url"
11 "os/exec"
12 "path/filepath"
13 "strconv"
14 "strings"
15 "testing"
16
17 "gitlab.com/Timfa/bluegit/internal/access"
18 "gitlab.com/Timfa/bluegit/internal/auth"
19 "gitlab.com/Timfa/bluegit/internal/config"
20 "gitlab.com/Timfa/bluegit/internal/gitrepo"
21 "gitlab.com/Timfa/bluegit/internal/store"
22 )
23
24 func TestPipelineRetryButtonAndAPI(t *testing.T) {
25 if _, err := exec.LookPath("git"); err != nil {
26 t.Skip("git ontbreekt")
27 }
28 storage := t.TempDir()
29 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
30 if err != nil {
31 t.Fatal(err)
32 }
33 t.Cleanup(func() { _ = st.Close() })
34 cfg := config.Config{
35 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
36 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
37 Git: config.Git{Binary: "git", DefaultBranch: "master"},
38 }
39 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
40 ts := httptest.NewServer(srv.Handler())
41 t.Cleanup(ts.Close)
42 jar, _ := cookiejar.New(nil)
43 tim := &http.Client{Jar: jar}
44 page := read(t, mustGet(t, tim, ts.URL+"/login"))
45 if _, err := tim.PostForm(ts.URL+"/new/repo", url.Values{
46 "csrf": {csrfOf(t, page)}, "name": {"opnieuw"}, "visibility": {"public"},
47 }); err != nil {
48 t.Fatal(err)
49 }
50 ctx := context.Background()
51 repo, err := st.RepoByPath(ctx, "tim", "opnieuw")
52 if err != nil {
53 t.Fatal(err)
54 }
55 ro, err := st.UpsertUser(ctx, 2, "ro", "", false)
56 if err != nil {
57 t.Fatal(err)
58 }
59 if err := st.SetMember(ctx, "repo", repo.ID, "ro", access.RoleReadonly); err != nil {
60 t.Fatal(err)
61 }
62 roToken, err := st.CreateToken(ctx, ro.ID, "ro")
63 if err != nil {
64 t.Fatal(err)
65 }
66 owner, err := st.UserByUsername(ctx, "tim")
67 if err != nil {
68 t.Fatal(err)
69 }
70 ownerToken, err := st.CreateToken(ctx, owner.ID, "tim")
71 if err != nil {
72 t.Fatal(err)
73 }
74
75 dir := gitrepo.Dir(storage, "tim", "opnieuw")
76 work := t.TempDir()
77 git(t, work, "init", "-b", "master")
78 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
79 git(t, work, "config", "user.name", "tim")
80 writeFile(t, filepath.Join(work, "README.md"), "hallo\n")
81 git(t, work, "add", "README.md")
82 git(t, work, "commit", "-m", "leesmij")
83 git(t, work, "remote", "add", "origin", dir)
84 git(t, work, "push", "origin", "master")
85 sha := strings.TrimSpace(mustGit(t, dir, "rev-parse", "refs/heads/master"))
86 git(t, dir, "branch", "topic", sha)
87
88 mr, err := st.CreateMergeRequest(ctx, repo.ID, owner.ID, "Opnieuw", "", "topic", "master")
89 if err != nil {
90 t.Fatal(err)
91 }
92 okID := makePipe(t, st, repo.ID, sha, "groen", []store.NewJob{
93 {Name: "lint", Stage: "test", Script: "exit 0"},
94 })
95 finishPipe(t, st, okID, "success")
96 id := makePipe(t, st, repo.ID, sha, "rood", []store.NewJob{
97 {Name: "lint", Stage: "test", Script: "exit 0"},
98 {Name: "unit", Stage: "test", Script: "exit 1"},
99 {Name: "pack", Stage: "deploy", Script: "exit 0"},
100 {Name: "pages", Stage: "deploy", Script: "exit 0", When: "manual"},
101 {Name: "aur", Stage: "deploy", Script: "echo aur", NeedsSet: true},
102 {Name: "note", Stage: "deploy", Script: "exit 0"},
103 })
104 jobs, err := st.JobsByPipeline(ctx, id)
105 if err != nil {
106 t.Fatal(err)
107 }
108 for _, j := range jobs {
109 switch j.Name {
110 case "lint", "aur":
111 if err := st.FinishJob(ctx, j.ID, "success", "ok\n"); err != nil {
112 t.Fatal(err)
113 }
114 case "unit":
115 if err := st.FinishJob(ctx, j.ID, "failed", "nee\n"); err != nil {
116 t.Fatal(err)
117 }
118 case "note":
119 if err := st.FinishJob(ctx, j.ID, "canceled", "stop\n"); err != nil {
120 t.Fatal(err)
121 }
122 case "pack", "pages":
123 if err := st.SkipJob(ctx, j.ID, "skipped\n"); err != nil {
124 t.Fatal(err)
125 }
126 }
127 }
128 if _, err := st.RefreshPipelineStatus(ctx, id); err != nil {
129 t.Fatal(err)
130 }
131 if err := st.AttachPipelineMR(ctx, id, mr.ID); err != nil {
132 t.Fatal(err)
133 }
134
135 list := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw/-/pipelines"))
136 detail := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)))
137 home := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw"))
138 mrPage := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw/-/merge-requests/1"))
139 for _, body := range []string{list, detail, home, mrPage} {
140 if !strings.Contains(body, `class="rowmenu piperetry"`) || !strings.Contains(body, "Retry entire pipeline") {
141 t.Fatalf("schrijver mist de knop:\n%s", body)
142 }
143 }
144 failedForm := `data-retry-failed data-pipe="` + strconv.FormatInt(id, 10) + `"`
145 okForm := `data-retry-failed data-pipe="` + strconv.FormatInt(okID, 10) + `" hidden`
146 if !strings.Contains(list, failedForm) || strings.Contains(list, failedForm+" hidden") || !strings.Contains(list, okForm) {
147 t.Fatalf("mislukte optie hoort alleen bij de rode pipeline:\n%s", list)
148 }
149 if !strings.Contains(detail, "Retry failed jobs") || strings.Contains(detail, failedForm+" hidden") {
150 t.Fatalf("detail mist de mislukte optie:\n%s", detail)
151 }
152 if !strings.Contains(home, "Retry failed jobs") || !strings.Contains(mrPage, "Retry failed jobs") {
153 t.Fatal("overzicht of merge request mist de mislukte optie")
154 }
155
156 anon := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw/-/pipelines"))
157 anonHome := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw"))
158 anonMR := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw/-/merge-requests/1"))
159 anonDetail := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)))
160 for _, body := range []string{anon, anonHome, anonMR, anonDetail} {
161 if strings.Contains(body, "piperetry") || strings.Contains(body, "Retry entire pipeline") {
162 t.Fatalf("lezer ziet de knop:\n%s", body)
163 }
164 }
165
166 code, body := retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", roToken, `{"mode":"failed"}`)
167 if code != 403 {
168 t.Fatalf("readonly api %d %s", code, body)
169 }
170 code, body = retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", ownerToken, `{"mode":"nope"}`)
171 if code != 400 {
172 t.Fatalf("mode %d %s", code, body)
173 }
174 res, err := http.PostForm(ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)+"/retry", url.Values{"mode": {"all"}})
175 if err != nil {
176 t.Fatal(err)
177 }
178 if res.StatusCode != http.StatusForbidden {
179 t.Fatalf("anonieme post %d", res.StatusCode)
180 }
181 res.Body.Close()
182
183 csrf := csrfOf(t, detail)
184 done := read(t, mustPost(t, tim, ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)+"/retry", url.Values{
185 "csrf": {csrf}, "mode": {"failed"}, "back": {"/tim/opnieuw/-/pipelines/" + strconv.FormatInt(id, 10)},
186 }))
187 if !strings.Contains(done, "Pipeline retried") || !strings.Contains(done, "Running") {
188 t.Fatalf("na mislukte jobs:\n%s", done)
189 }
190 if !strings.Contains(done, failedForm+" hidden") {
191 t.Fatalf("optie blijft staan zonder mislukking:\n%s", done)
192 }
193 got := map[string]string{}
194 jobs, err = st.JobsByPipeline(ctx, id)
195 if err != nil {
196 t.Fatal(err)
197 }
198 for _, j := range jobs {
199 got[j.Name] = j.Status
200 }
201 if got["lint"] != "success" || got["aur"] != "success" || got["unit"] != "queued" || got["pack"] != "queued" || got["pages"] != "manual" || got["note"] != "canceled" {
202 t.Fatalf("jobs na retry: %v", got)
203 }
204 p, err := st.PipelineByID(ctx, repo.ID, id)
205 if err != nil || p.Status != "running" {
206 t.Fatalf("pipelinestatus %s %v", p.Status, err)
207 }
208
209 code, body = retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", ownerToken, `{"mode":"failed"}`)
210 if code != 409 {
211 t.Fatalf("tweede failed %d %s", code, body)
212 }
213 code, body = retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", ownerToken, `{"mode":"all"}`)
214 if code != 201 {
215 t.Fatalf("all %d %s", code, body)
216 }
217 var created map[string]any
218 if err := json.Unmarshal([]byte(body), &created); err != nil {
219 t.Fatal(err)
220 }
221 newID, _ := created["id"].(float64)
222 if int64(newID) == id || created["sha"] != sha || created["source"] != "push" && created["source"] != "merge_request_event" {
223 t.Fatalf("antwoord %s", body)
224 }
225 clone, err := st.PipelineByID(ctx, repo.ID, int64(newID))
226 if err != nil {
227 t.Fatal(err)
228 }
229 if clone.CommitSHA != sha || clone.Ref != "refs/heads/master" || clone.Source != "push" || clone.MRID != mr.ID || clone.Status != "queued" {
230 t.Fatalf("kloon %+v", clone)
231 }
232 old, err := st.PipelineByID(ctx, repo.ID, id)
233 if err != nil || old.Status != "running" {
234 t.Fatalf("oude pipeline %s %v", old.Status, err)
235 }
236 }
237
238 func retryAPI(t *testing.T, ts *httptest.Server, method, path, token, body string) (int, string) {
239 t.Helper()
240 req, err := http.NewRequest(method, ts.URL+path, strings.NewReader(body))
241 if err != nil {
242 t.Fatal(err)
243 }
244 req.Header.Set("Content-Type", "application/json")
245 req.Header.Set("Authorization", "Bearer "+token)
246 res, err := http.DefaultClient.Do(req)
247 if err != nil {
248 t.Fatal(err)
249 }
250 defer res.Body.Close()
251 raw, err := io.ReadAll(res.Body)
252 if err != nil {
253 t.Fatal(err)
254 }
255 return res.StatusCode, string(raw)
256 }
@@ -0,0 +1,256 @@
1package server
2
3import (
4 "context"
5 "encoding/json"
6 "io"
7 "net/http"
8 "net/http/cookiejar"
9 "net/http/httptest"
10 "net/url"
11 "os/exec"
12 "path/filepath"
13 "strconv"
14 "strings"
15 "testing"
16
17 "gitlab.com/Timfa/bluegit/internal/access"
18 "gitlab.com/Timfa/bluegit/internal/auth"
19 "gitlab.com/Timfa/bluegit/internal/config"
20 "gitlab.com/Timfa/bluegit/internal/gitrepo"
21 "gitlab.com/Timfa/bluegit/internal/store"
22)
23
24func TestPipelineRetryButtonAndAPI(t *testing.T) {
25 if _, err := exec.LookPath("git"); err != nil {
26 t.Skip("git ontbreekt")
27 }
28 storage := t.TempDir()
29 st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
30 if err != nil {
31 t.Fatal(err)
32 }
33 t.Cleanup(func() { _ = st.Close() })
34 cfg := config.Config{
35 BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
36 Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
37 Git: config.Git{Binary: "git", DefaultBranch: "master"},
38 }
39 srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
40 ts := httptest.NewServer(srv.Handler())
41 t.Cleanup(ts.Close)
42 jar, _ := cookiejar.New(nil)
43 tim := &http.Client{Jar: jar}
44 page := read(t, mustGet(t, tim, ts.URL+"/login"))
45 if _, err := tim.PostForm(ts.URL+"/new/repo", url.Values{
46 "csrf": {csrfOf(t, page)}, "name": {"opnieuw"}, "visibility": {"public"},
47 }); err != nil {
48 t.Fatal(err)
49 }
50 ctx := context.Background()
51 repo, err := st.RepoByPath(ctx, "tim", "opnieuw")
52 if err != nil {
53 t.Fatal(err)
54 }
55 ro, err := st.UpsertUser(ctx, 2, "ro", "", false)
56 if err != nil {
57 t.Fatal(err)
58 }
59 if err := st.SetMember(ctx, "repo", repo.ID, "ro", access.RoleReadonly); err != nil {
60 t.Fatal(err)
61 }
62 roToken, err := st.CreateToken(ctx, ro.ID, "ro")
63 if err != nil {
64 t.Fatal(err)
65 }
66 owner, err := st.UserByUsername(ctx, "tim")
67 if err != nil {
68 t.Fatal(err)
69 }
70 ownerToken, err := st.CreateToken(ctx, owner.ID, "tim")
71 if err != nil {
72 t.Fatal(err)
73 }
74
75 dir := gitrepo.Dir(storage, "tim", "opnieuw")
76 work := t.TempDir()
77 git(t, work, "init", "-b", "master")
78 git(t, work, "config", "user.email", "tim@users.git.timfalken.com")
79 git(t, work, "config", "user.name", "tim")
80 writeFile(t, filepath.Join(work, "README.md"), "hallo\n")
81 git(t, work, "add", "README.md")
82 git(t, work, "commit", "-m", "leesmij")
83 git(t, work, "remote", "add", "origin", dir)
84 git(t, work, "push", "origin", "master")
85 sha := strings.TrimSpace(mustGit(t, dir, "rev-parse", "refs/heads/master"))
86 git(t, dir, "branch", "topic", sha)
87
88 mr, err := st.CreateMergeRequest(ctx, repo.ID, owner.ID, "Opnieuw", "", "topic", "master")
89 if err != nil {
90 t.Fatal(err)
91 }
92 okID := makePipe(t, st, repo.ID, sha, "groen", []store.NewJob{
93 {Name: "lint", Stage: "test", Script: "exit 0"},
94 })
95 finishPipe(t, st, okID, "success")
96 id := makePipe(t, st, repo.ID, sha, "rood", []store.NewJob{
97 {Name: "lint", Stage: "test", Script: "exit 0"},
98 {Name: "unit", Stage: "test", Script: "exit 1"},
99 {Name: "pack", Stage: "deploy", Script: "exit 0"},
100 {Name: "pages", Stage: "deploy", Script: "exit 0", When: "manual"},
101 {Name: "aur", Stage: "deploy", Script: "echo aur", NeedsSet: true},
102 {Name: "note", Stage: "deploy", Script: "exit 0"},
103 })
104 jobs, err := st.JobsByPipeline(ctx, id)
105 if err != nil {
106 t.Fatal(err)
107 }
108 for _, j := range jobs {
109 switch j.Name {
110 case "lint", "aur":
111 if err := st.FinishJob(ctx, j.ID, "success", "ok\n"); err != nil {
112 t.Fatal(err)
113 }
114 case "unit":
115 if err := st.FinishJob(ctx, j.ID, "failed", "nee\n"); err != nil {
116 t.Fatal(err)
117 }
118 case "note":
119 if err := st.FinishJob(ctx, j.ID, "canceled", "stop\n"); err != nil {
120 t.Fatal(err)
121 }
122 case "pack", "pages":
123 if err := st.SkipJob(ctx, j.ID, "skipped\n"); err != nil {
124 t.Fatal(err)
125 }
126 }
127 }
128 if _, err := st.RefreshPipelineStatus(ctx, id); err != nil {
129 t.Fatal(err)
130 }
131 if err := st.AttachPipelineMR(ctx, id, mr.ID); err != nil {
132 t.Fatal(err)
133 }
134
135 list := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw/-/pipelines"))
136 detail := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)))
137 home := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw"))
138 mrPage := read(t, mustGet(t, tim, ts.URL+"/tim/opnieuw/-/merge-requests/1"))
139 for _, body := range []string{list, detail, home, mrPage} {
140 if !strings.Contains(body, `class="rowmenu piperetry"`) || !strings.Contains(body, "Retry entire pipeline") {
141 t.Fatalf("schrijver mist de knop:\n%s", body)
142 }
143 }
144 failedForm := `data-retry-failed data-pipe="` + strconv.FormatInt(id, 10) + `"`
145 okForm := `data-retry-failed data-pipe="` + strconv.FormatInt(okID, 10) + `" hidden`
146 if !strings.Contains(list, failedForm) || strings.Contains(list, failedForm+" hidden") || !strings.Contains(list, okForm) {
147 t.Fatalf("mislukte optie hoort alleen bij de rode pipeline:\n%s", list)
148 }
149 if !strings.Contains(detail, "Retry failed jobs") || strings.Contains(detail, failedForm+" hidden") {
150 t.Fatalf("detail mist de mislukte optie:\n%s", detail)
151 }
152 if !strings.Contains(home, "Retry failed jobs") || !strings.Contains(mrPage, "Retry failed jobs") {
153 t.Fatal("overzicht of merge request mist de mislukte optie")
154 }
155
156 anon := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw/-/pipelines"))
157 anonHome := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw"))
158 anonMR := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw/-/merge-requests/1"))
159 anonDetail := read(t, mustGet(t, http.DefaultClient, ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)))
160 for _, body := range []string{anon, anonHome, anonMR, anonDetail} {
161 if strings.Contains(body, "piperetry") || strings.Contains(body, "Retry entire pipeline") {
162 t.Fatalf("lezer ziet de knop:\n%s", body)
163 }
164 }
165
166 code, body := retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", roToken, `{"mode":"failed"}`)
167 if code != 403 {
168 t.Fatalf("readonly api %d %s", code, body)
169 }
170 code, body = retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", ownerToken, `{"mode":"nope"}`)
171 if code != 400 {
172 t.Fatalf("mode %d %s", code, body)
173 }
174 res, err := http.PostForm(ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)+"/retry", url.Values{"mode": {"all"}})
175 if err != nil {
176 t.Fatal(err)
177 }
178 if res.StatusCode != http.StatusForbidden {
179 t.Fatalf("anonieme post %d", res.StatusCode)
180 }
181 res.Body.Close()
182
183 csrf := csrfOf(t, detail)
184 done := read(t, mustPost(t, tim, ts.URL+"/tim/opnieuw/-/pipelines/"+strconv.FormatInt(id, 10)+"/retry", url.Values{
185 "csrf": {csrf}, "mode": {"failed"}, "back": {"/tim/opnieuw/-/pipelines/" + strconv.FormatInt(id, 10)},
186 }))
187 if !strings.Contains(done, "Pipeline retried") || !strings.Contains(done, "Running") {
188 t.Fatalf("na mislukte jobs:\n%s", done)
189 }
190 if !strings.Contains(done, failedForm+" hidden") {
191 t.Fatalf("optie blijft staan zonder mislukking:\n%s", done)
192 }
193 got := map[string]string{}
194 jobs, err = st.JobsByPipeline(ctx, id)
195 if err != nil {
196 t.Fatal(err)
197 }
198 for _, j := range jobs {
199 got[j.Name] = j.Status
200 }
201 if got["lint"] != "success" || got["aur"] != "success" || got["unit"] != "queued" || got["pack"] != "queued" || got["pages"] != "manual" || got["note"] != "canceled" {
202 t.Fatalf("jobs na retry: %v", got)
203 }
204 p, err := st.PipelineByID(ctx, repo.ID, id)
205 if err != nil || p.Status != "running" {
206 t.Fatalf("pipelinestatus %s %v", p.Status, err)
207 }
208
209 code, body = retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", ownerToken, `{"mode":"failed"}`)
210 if code != 409 {
211 t.Fatalf("tweede failed %d %s", code, body)
212 }
213 code, body = retryAPI(t, ts, http.MethodPost, "/api/v1/projects/tim/opnieuw/pipelines/"+strconv.FormatInt(id, 10)+"/retry", ownerToken, `{"mode":"all"}`)
214 if code != 201 {
215 t.Fatalf("all %d %s", code, body)
216 }
217 var created map[string]any
218 if err := json.Unmarshal([]byte(body), &created); err != nil {
219 t.Fatal(err)
220 }
221 newID, _ := created["id"].(float64)
222 if int64(newID) == id || created["sha"] != sha || created["source"] != "push" && created["source"] != "merge_request_event" {
223 t.Fatalf("antwoord %s", body)
224 }
225 clone, err := st.PipelineByID(ctx, repo.ID, int64(newID))
226 if err != nil {
227 t.Fatal(err)
228 }
229 if clone.CommitSHA != sha || clone.Ref != "refs/heads/master" || clone.Source != "push" || clone.MRID != mr.ID || clone.Status != "queued" {
230 t.Fatalf("kloon %+v", clone)
231 }
232 old, err := st.PipelineByID(ctx, repo.ID, id)
233 if err != nil || old.Status != "running" {
234 t.Fatalf("oude pipeline %s %v", old.Status, err)
235 }
236}
237
238func retryAPI(t *testing.T, ts *httptest.Server, method, path, token, body string) (int, string) {
239 t.Helper()
240 req, err := http.NewRequest(method, ts.URL+path, strings.NewReader(body))
241 if err != nil {
242 t.Fatal(err)
243 }
244 req.Header.Set("Content-Type", "application/json")
245 req.Header.Set("Authorization", "Bearer "+token)
246 res, err := http.DefaultClient.Do(req)
247 if err != nil {
248 t.Fatal(err)
249 }
250 defer res.Body.Close()
251 raw, err := io.ReadAll(res.Body)
252 if err != nil {
253 t.Fatal(err)
254 }
255 return res.StatusCode, string(raw)
256}
internal/server/profile_test.go +65 −4
@@ -73,12 +73,19 @@ func TestProfilePage(t *testing.T) {
73 73 if err := st.SetLogoMIME(ctx, "repo", zichtbaar.ID, "image/png"); err != nil {
74 74 t.Fatal(err)
75 75 }
76 if _, err := st.CreateRepo(ctx, "user", tim.ID, "geheim", "Geheim project", "master", "private"); err != nil {
76 geheim, err := st.CreateRepo(ctx, "user", tim.ID, "geheim", "Geheim project", "master", "private")
77 if err != nil {
77 78 t.Fatal(err)
78 79 }
79 80 if _, err := st.CreateRepo(ctx, "group", plein.ID, "gedeeld", "Groepsrepo", "master", "public"); err != nil {
80 81 t.Fatal(err)
81 82 }
83 if err := st.AddContributions(ctx, []store.Contribution{
84 {UserID: tim.ID, RepoID: zichtbaar.ID, Kind: "commit", Ref: "pub", At: time.Now()},
85 {UserID: tim.ID, RepoID: geheim.ID, Kind: "commit", Ref: "priv", At: time.Now()},
86 }); err != nil {
87 t.Fatal(err)
88 }
82 89 if err := st.SetMember(ctx, "repo", repoID(t, st, "tim", "geheim"), "ada", access.RoleDeveloper); err != nil {
83 90 t.Fatal(err)
84 91 }
@@ -130,6 +137,7 @@ func TestProfilePage(t *testing.T) {
130 137 `href="/groups/plein"`,
131 138 `<strong>1</strong> <span>Repositories</span>`,
132 139 `<strong>1</strong> <span>Groups</span>`,
140 `<strong>1</strong> <span>Contributions</span>`,
133 141 } {
134 142 if !strings.Contains(pub, want) {
135 143 t.Fatalf("openbaar profiel mist %q", want)
@@ -160,6 +168,7 @@ func TestProfilePage(t *testing.T) {
160 168 `href="/groups/kluis"`,
161 169 `<strong>2</strong> <span>Repositories</span>`,
162 170 `<strong>2</strong> <span>Groups</span>`,
171 `<strong>2</strong> <span>Contributions</span>`,
163 172 } {
164 173 if !strings.Contains(adaPage, want) {
165 174 t.Fatalf("ada ziet niet %q", want)
@@ -224,7 +233,7 @@ func TestProfilePage(t *testing.T) {
224 233 t.Fatalf("api zelf mist eigen velden: %#v", mine)
225 234 }
226 235 counts := mine["counts"].(map[string]any)
227 if counts["repos"] != 2.0 || counts["groups"] != 2.0 || counts["contributions"] != 0.0 {
236 if counts["repos"] != 2.0 || counts["groups"] != 2.0 || counts["contributions"] != 2.0 {
228 237 t.Fatalf("api tellingen: %#v", counts)
229 238 }
230 239 if !apiPaths(mine["repos"]).has("tim/zichtbaar", "tim/geheim") || apiPaths(mine["repos"]).has("plein/gedeeld") {
@@ -240,6 +249,32 @@ func TestProfilePage(t *testing.T) {
240 249 if !apiPaths(other["repos"]).has("tim/geheim") || !apiPaths(other["groups"]).has("kluis") {
241 250 t.Fatalf("api van ada mist privé: %#v %#v", other["repos"], other["groups"])
242 251 }
252 if other["counts"].(map[string]any)["contributions"] != 2.0 {
253 t.Fatalf("api van ada telt verborgen bijdragen niet mee: %#v", other["counts"])
254 }
255 pubAPI := apiGet(t, ts.URL+"/api/v1/users/tim", "")
256 if _, ok := pubAPI["instance_admin"]; ok || pubAPI["language"] != nil {
257 t.Fatalf("anonieme api toont privévelden: %#v", pubAPI)
258 }
259 if apiPaths(pubAPI["repos"]).has("tim/geheim") || apiPaths(pubAPI["groups"]).has("kluis") || !apiPaths(pubAPI["repos"]).has("tim/zichtbaar") {
260 t.Fatalf("anonieme api filter: %#v %#v", pubAPI["repos"], pubAPI["groups"])
261 }
262 if pubAPI["counts"].(map[string]any)["contributions"] != 1.0 {
263 t.Fatalf("anonieme api lekt privébijdragen: %#v", pubAPI["counts"])
264 }
265 badTok, err := http.NewRequest(http.MethodGet, ts.URL+"/api/v1/users/tim", nil)
266 if err != nil {
267 t.Fatal(err)
268 }
269 badTok.Header.Set("Authorization", "Bearer bg_nietgeldig")
270 res, err = http.DefaultClient.Do(badTok)
271 if err != nil {
272 t.Fatal(err)
273 }
274 if res.StatusCode != http.StatusUnauthorized {
275 t.Fatalf("ongeldig token %d", res.StatusCode)
276 }
277 _ = res.Body.Close()
243 278 req, err := http.NewRequest(http.MethodPut, ts.URL+"/api/v1/user", strings.NewReader(`{"bio":"alleen bio"}`))
244 279 if err != nil {
245 280 t.Fatal(err)
@@ -261,10 +296,34 @@ func TestProfilePage(t *testing.T) {
261 296 t.Fatal(err)
262 297 }
263 298 loc := res.Header.Get("Location")
264 if res.StatusCode != http.StatusNotFound || loc != "" {
299 if res.StatusCode != http.StatusFound || loc != "/users/tim" {
265 300 t.Fatalf("/tim is %d locatie %q", res.StatusCode, loc)
266 301 }
267 302 _ = res.Body.Close()
303 res, err = noredir.Get(ts.URL + "/plein")
304 if err != nil {
305 t.Fatal(err)
306 }
307 if res.StatusCode != http.StatusNotFound || res.Header.Get("Location") != "" {
308 t.Fatalf("groepsnaam /plein is %d locatie %q", res.StatusCode, res.Header.Get("Location"))
309 }
310 _ = res.Body.Close()
311 res, err = noredir.Get(ts.URL + "/tim/zichtbaar")
312 if err != nil {
313 t.Fatal(err)
314 }
315 if res.StatusCode == http.StatusFound && strings.HasPrefix(res.Header.Get("Location"), "/users/") {
316 t.Fatalf("repositorypad wijst naar een profiel: %s", res.Header.Get("Location"))
317 }
318 _ = res.Body.Close()
319 res, err = noredir.Get(ts.URL + "/login")
320 if err != nil {
321 t.Fatal(err)
322 }
323 if strings.Contains(res.Header.Get("Location"), "/users/") {
324 t.Fatalf("login wijst naar een profiel: %s", res.Header.Get("Location"))
325 }
326 _ = res.Body.Close()
268 327 res, err = anon.Get(ts.URL + "/users/nobody")
269 328 if err != nil {
270 329 t.Fatal(err)
@@ -291,7 +350,9 @@ func apiGet(t *testing.T, rawURL, token string) map[string]any {
291 350 if err != nil {
292 351 t.Fatal(err)
293 352 }
294 req.Header.Set("Authorization", "Bearer "+token)
353 if token != "" {
354 req.Header.Set("Authorization", "Bearer "+token)
355 }
295 356 res, err := http.DefaultClient.Do(req)
296 357 if err != nil {
297 358 t.Fatal(err)
@@ -73,12 +73,19 @@ func TestProfilePage(t *testing.T) {
73 if err := st.SetLogoMIME(ctx, "repo", zichtbaar.ID, "image/png"); err != nil {
73 if err := st.SetLogoMIME(ctx, "repo", zichtbaar.ID, "image/png"); err != nil {
74 t.Fatal(err)
74 t.Fatal(err)
75 }
75 }
76 if _, err := st.CreateRepo(ctx, "user", tim.ID, "geheim", "Geheim project", "master", "private"); err != nil {
76 geheim, err := st.CreateRepo(ctx, "user", tim.ID, "geheim", "Geheim project", "master", "private")
77 if err != nil {
77 t.Fatal(err)
78 t.Fatal(err)
78 }
79 }
79 if _, err := st.CreateRepo(ctx, "group", plein.ID, "gedeeld", "Groepsrepo", "master", "public"); err != nil {
80 if _, err := st.CreateRepo(ctx, "group", plein.ID, "gedeeld", "Groepsrepo", "master", "public"); err != nil {
80 t.Fatal(err)
81 t.Fatal(err)
81 }
82 }
83 if err := st.AddContributions(ctx, []store.Contribution{
84 {UserID: tim.ID, RepoID: zichtbaar.ID, Kind: "commit", Ref: "pub", At: time.Now()},
85 {UserID: tim.ID, RepoID: geheim.ID, Kind: "commit", Ref: "priv", At: time.Now()},
86 }); err != nil {
87 t.Fatal(err)
88 }
82 if err := st.SetMember(ctx, "repo", repoID(t, st, "tim", "geheim"), "ada", access.RoleDeveloper); err != nil {
89 if err := st.SetMember(ctx, "repo", repoID(t, st, "tim", "geheim"), "ada", access.RoleDeveloper); err != nil {
83 t.Fatal(err)
90 t.Fatal(err)
84 }
91 }
@@ -130,6 +137,7 @@ func TestProfilePage(t *testing.T) {
130 `href="/groups/plein"`,
137 `href="/groups/plein"`,
131 `<strong>1</strong> <span>Repositories</span>`,
138 `<strong>1</strong> <span>Repositories</span>`,
132 `<strong>1</strong> <span>Groups</span>`,
139 `<strong>1</strong> <span>Groups</span>`,
140 `<strong>1</strong> <span>Contributions</span>`,
133 } {
141 } {
134 if !strings.Contains(pub, want) {
142 if !strings.Contains(pub, want) {
135 t.Fatalf("openbaar profiel mist %q", want)
143 t.Fatalf("openbaar profiel mist %q", want)
@@ -160,6 +168,7 @@ func TestProfilePage(t *testing.T) {
160 `href="/groups/kluis"`,
168 `href="/groups/kluis"`,
161 `<strong>2</strong> <span>Repositories</span>`,
169 `<strong>2</strong> <span>Repositories</span>`,
162 `<strong>2</strong> <span>Groups</span>`,
170 `<strong>2</strong> <span>Groups</span>`,
171 `<strong>2</strong> <span>Contributions</span>`,
163 } {
172 } {
164 if !strings.Contains(adaPage, want) {
173 if !strings.Contains(adaPage, want) {
165 t.Fatalf("ada ziet niet %q", want)
174 t.Fatalf("ada ziet niet %q", want)
@@ -224,7 +233,7 @@ func TestProfilePage(t *testing.T) {
224 t.Fatalf("api zelf mist eigen velden: %#v", mine)
233 t.Fatalf("api zelf mist eigen velden: %#v", mine)
225 }
234 }
226 counts := mine["counts"].(map[string]any)
235 counts := mine["counts"].(map[string]any)
227 if counts["repos"] != 2.0 || counts["groups"] != 2.0 || counts["contributions"] != 0.0 {
236 if counts["repos"] != 2.0 || counts["groups"] != 2.0 || counts["contributions"] != 2.0 {
228 t.Fatalf("api tellingen: %#v", counts)
237 t.Fatalf("api tellingen: %#v", counts)
229 }
238 }
230 if !apiPaths(mine["repos"]).has("tim/zichtbaar", "tim/geheim") || apiPaths(mine["repos"]).has("plein/gedeeld") {
239 if !apiPaths(mine["repos"]).has("tim/zichtbaar", "tim/geheim") || apiPaths(mine["repos"]).has("plein/gedeeld") {
@@ -240,6 +249,32 @@ func TestProfilePage(t *testing.T) {
240 if !apiPaths(other["repos"]).has("tim/geheim") || !apiPaths(other["groups"]).has("kluis") {
249 if !apiPaths(other["repos"]).has("tim/geheim") || !apiPaths(other["groups"]).has("kluis") {
241 t.Fatalf("api van ada mist privé: %#v %#v", other["repos"], other["groups"])
250 t.Fatalf("api van ada mist privé: %#v %#v", other["repos"], other["groups"])
242 }
251 }
252 if other["counts"].(map[string]any)["contributions"] != 2.0 {
253 t.Fatalf("api van ada telt verborgen bijdragen niet mee: %#v", other["counts"])
254 }
255 pubAPI := apiGet(t, ts.URL+"/api/v1/users/tim", "")
256 if _, ok := pubAPI["instance_admin"]; ok || pubAPI["language"] != nil {
257 t.Fatalf("anonieme api toont privévelden: %#v", pubAPI)
258 }
259 if apiPaths(pubAPI["repos"]).has("tim/geheim") || apiPaths(pubAPI["groups"]).has("kluis") || !apiPaths(pubAPI["repos"]).has("tim/zichtbaar") {
260 t.Fatalf("anonieme api filter: %#v %#v", pubAPI["repos"], pubAPI["groups"])
261 }
262 if pubAPI["counts"].(map[string]any)["contributions"] != 1.0 {
263 t.Fatalf("anonieme api lekt privébijdragen: %#v", pubAPI["counts"])
264 }
265 badTok, err := http.NewRequest(http.MethodGet, ts.URL+"/api/v1/users/tim", nil)
266 if err != nil {
267 t.Fatal(err)
268 }
269 badTok.Header.Set("Authorization", "Bearer bg_nietgeldig")
270 res, err = http.DefaultClient.Do(badTok)
271 if err != nil {
272 t.Fatal(err)
273 }
274 if res.StatusCode != http.StatusUnauthorized {
275 t.Fatalf("ongeldig token %d", res.StatusCode)
276 }
277 _ = res.Body.Close()
243 req, err := http.NewRequest(http.MethodPut, ts.URL+"/api/v1/user", strings.NewReader(`{"bio":"alleen bio"}`))
278 req, err := http.NewRequest(http.MethodPut, ts.URL+"/api/v1/user", strings.NewReader(`{"bio":"alleen bio"}`))
244 if err != nil {
279 if err != nil {
245 t.Fatal(err)
280 t.Fatal(err)
@@ -261,10 +296,34 @@ func TestProfilePage(t *testing.T) {
261 t.Fatal(err)
296 t.Fatal(err)
262 }
297 }
263 loc := res.Header.Get("Location")
298 loc := res.Header.Get("Location")
264 if res.StatusCode != http.StatusNotFound || loc != "" {
299 if res.StatusCode != http.StatusFound || loc != "/users/tim" {
265 t.Fatalf("/tim is %d locatie %q", res.StatusCode, loc)
300 t.Fatalf("/tim is %d locatie %q", res.StatusCode, loc)
266 }
301 }
267 _ = res.Body.Close()
302 _ = res.Body.Close()
303 res, err = noredir.Get(ts.URL + "/plein")
304 if err != nil {
305 t.Fatal(err)
306 }
307 if res.StatusCode != http.StatusNotFound || res.Header.Get("Location") != "" {
308 t.Fatalf("groepsnaam /plein is %d locatie %q", res.StatusCode, res.Header.Get("Location"))
309 }
310 _ = res.Body.Close()
311 res, err = noredir.Get(ts.URL + "/tim/zichtbaar")
312 if err != nil {
313 t.Fatal(err)
314 }
315 if res.StatusCode == http.StatusFound && strings.HasPrefix(res.Header.Get("Location"), "/users/") {
316 t.Fatalf("repositorypad wijst naar een profiel: %s", res.Header.Get("Location"))
317 }
318 _ = res.Body.Close()
319 res, err = noredir.Get(ts.URL + "/login")
320 if err != nil {
321 t.Fatal(err)
322 }
323 if strings.Contains(res.Header.Get("Location"), "/users/") {
324 t.Fatalf("login wijst naar een profiel: %s", res.Header.Get("Location"))
325 }
326 _ = res.Body.Close()
268 res, err = anon.Get(ts.URL + "/users/nobody")
327 res, err = anon.Get(ts.URL + "/users/nobody")
269 if err != nil {
328 if err != nil {
270 t.Fatal(err)
329 t.Fatal(err)
@@ -291,7 +350,9 @@ func apiGet(t *testing.T, rawURL, token string) map[string]any {
291 if err != nil {
350 if err != nil {
292 t.Fatal(err)
351 t.Fatal(err)
293 }
352 }
294 req.Header.Set("Authorization", "Bearer "+token)
353 if token != "" {
354 req.Header.Set("Authorization", "Bearer "+token)
355 }
295 res, err := http.DefaultClient.Do(req)
356 res, err := http.DefaultClient.Do(req)
296 if err != nil {
357 if err != nil {
297 t.Fatal(err)
358 t.Fatal(err)
internal/server/project.go +1 −0
@@ -123,6 +123,7 @@ func (s *Server) attachHeadPipeline(ctx context.Context, repo store.Repo, row *C
123 123 tr := func(key string, args ...any) string { return i18n.T(lang, key, args...) }
124 124 row.PipeStages = stageViews(jobs, s.queueRanks(ctx), tr)
125 125 row.PipeLive = jobsLive(p.Status, jobs)
126 row.PipeFailed = jobsFailed(jobs)
126 127 }
127 128
128 129 func fileRows(entries []gitrepo.Entry, base string, touch map[string]gitrepo.Commit, lang i18n.Lang) []FileRow {
@@ -123,6 +123,7 @@ func (s *Server) attachHeadPipeline(ctx context.Context, repo store.Repo, row *C
123 tr := func(key string, args ...any) string { return i18n.T(lang, key, args...) }
123 tr := func(key string, args ...any) string { return i18n.T(lang, key, args...) }
124 row.PipeStages = stageViews(jobs, s.queueRanks(ctx), tr)
124 row.PipeStages = stageViews(jobs, s.queueRanks(ctx), tr)
125 row.PipeLive = jobsLive(p.Status, jobs)
125 row.PipeLive = jobsLive(p.Status, jobs)
126 row.PipeFailed = jobsFailed(jobs)
126}
127}
127
128
128func fileRows(entries []gitrepo.Entry, base string, touch map[string]gitrepo.Commit, lang i18n.Lang) []FileRow {
129func fileRows(entries []gitrepo.Entry, base string, touch map[string]gitrepo.Commit, lang i18n.Lang) []FileRow {
internal/server/repo_handlers.go +22 −8
@@ -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
@@ -174,12 +190,9 @@ func (s *Server) mergeRequests(w http.ResponseWriter, r *http.Request) {
174 190 s.absorbMergedMRs(r.Context(), repo)
175 191 v := s.repoView(w, r, repo, role, "title.mrs")
176 192 v.Page = "mrs"
177 v.MRs, _ = s.Store.ListMergeRequests(r.Context(), repo.ID)
178 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
179 names, _ := gitrepo.Branches(r.Context(), s.Git, dir)
180 for _, name := range names {
181 v.Branches = append(v.Branches, BranchRow{Name: name})
182 }
193 v.Wide = true
194 all, _ := s.Store.ListMergeRequests(r.Context(), repo.ID)
195 v.Flow = s.flowMRs(r, repo, role, all)
183 196 s.render(w, "mrs", v)
184 197 }
185 198
@@ -370,6 +383,7 @@ func (s *Server) pipeline(w http.ResponseWriter, r *http.Request) {
370 383 v.PipeSource = s.pipelineSourceText(r, repo, p)
371 384 v.PipeJobs = linksFor(jobs, ranks, tr)
372 385 v.PipeStages = stageViews(jobs, ranks, tr)
386 v.PipeFailed = jobsFailed(jobs)
373 387 v.Live = jobsLive(p.Status, jobs)
374 388 v.LiveURL = repoURL(repo) + "/-/pipelines/" + strconv.FormatInt(p.ID, 10)
375 389 if wantsJSON(r) {
@@ -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 = true
133 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 = 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 s.render(w, "commits", v)
151 s.render(w, "commits", v)
136}
152}
137
153
@@ -174,12 +190,9 @@ func (s *Server) mergeRequests(w http.ResponseWriter, r *http.Request) {
174 s.absorbMergedMRs(r.Context(), repo)
190 s.absorbMergedMRs(r.Context(), repo)
175 v := s.repoView(w, r, repo, role, "title.mrs")
191 v := s.repoView(w, r, repo, role, "title.mrs")
176 v.Page = "mrs"
192 v.Page = "mrs"
177 v.MRs, _ = s.Store.ListMergeRequests(r.Context(), repo.ID)
193 v.Wide = true
178 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
194 all, _ := s.Store.ListMergeRequests(r.Context(), repo.ID)
179 names, _ := gitrepo.Branches(r.Context(), s.Git, dir)
195 v.Flow = s.flowMRs(r, repo, role, all)
180 for _, name := range names {
181 v.Branches = append(v.Branches, BranchRow{Name: name})
182 }
183 s.render(w, "mrs", v)
196 s.render(w, "mrs", v)
184}
197}
185
198
@@ -370,6 +383,7 @@ func (s *Server) pipeline(w http.ResponseWriter, r *http.Request) {
370 v.PipeSource = s.pipelineSourceText(r, repo, p)
383 v.PipeSource = s.pipelineSourceText(r, repo, p)
371 v.PipeJobs = linksFor(jobs, ranks, tr)
384 v.PipeJobs = linksFor(jobs, ranks, tr)
372 v.PipeStages = stageViews(jobs, ranks, tr)
385 v.PipeStages = stageViews(jobs, ranks, tr)
386 v.PipeFailed = jobsFailed(jobs)
373 v.Live = jobsLive(p.Status, jobs)
387 v.Live = jobsLive(p.Status, jobs)
374 v.LiveURL = repoURL(repo) + "/-/pipelines/" + strconv.FormatInt(p.ID, 10)
388 v.LiveURL = repoURL(repo) + "/-/pipelines/" + strconv.FormatInt(p.ID, 10)
375 if wantsJSON(r) {
389 if wantsJSON(r) {
internal/server/reviews_test.go +1 −1
@@ -264,7 +264,7 @@ func TestReviewsApprovalsAndReopen(t *testing.T) {
264 264 t.Fatal(err)
265 265 }
266 266 body = read(t, res)
267 if !strings.Contains(body, ">open<") && !strings.Contains(body, "pill\">open") {
267 if !strings.Contains(body, ">open<") && !strings.Contains(body, "pill\">open") && !strings.Contains(body, "mrstate open") {
268 268 t.Fatalf("heropend:\n%s", body)
269 269 }
270 270 }
@@ -264,7 +264,7 @@ func TestReviewsApprovalsAndReopen(t *testing.T) {
264 t.Fatal(err)
264 t.Fatal(err)
265 }
265 }
266 body = read(t, res)
266 body = read(t, res)
267 if !strings.Contains(body, ">open<") && !strings.Contains(body, "pill\">open") {
267 if !strings.Contains(body, ">open<") && !strings.Contains(body, "pill\">open") && !strings.Contains(body, "mrstate open") {
268 t.Fatalf("heropend:\n%s", body)
268 t.Fatalf("heropend:\n%s", body)
269 }
269 }
270}
270}
internal/server/server.go +61 −10
@@ -6,6 +6,7 @@ import (
6 6 "crypto/rand"
7 7 "embed"
8 8 "encoding/hex"
9 "fmt"
9 10 "html/template"
10 11 "io/fs"
11 12 "log/slog"
@@ -106,6 +107,7 @@ func (s *Server) Handler() http.Handler {
106 107 mux.HandleFunc("POST /settings/ssh/delete", s.deleteSSH)
107 108 mux.HandleFunc("GET /settings/export", s.export)
108 109 mux.HandleFunc("GET /users/{username}", s.profile)
110 mux.HandleFunc("GET /{name}", s.userShort)
109 111 mux.HandleFunc("GET /groups/{path}", s.groupPage)
110 112 mux.HandleFunc("GET /groups/{path}/logo", s.groupLogo)
111 113 mux.HandleFunc("POST /groups/{path}/settings", s.saveGroup)
@@ -164,7 +166,9 @@ func (s *Server) Handler() http.Handler {
164 166 mux.HandleFunc("POST /{owner}/{repo}/-/tags", s.createTag)
165 167 mux.HandleFunc("POST /{owner}/{repo}/-/tags/delete", s.deleteTag)
166 168 mux.HandleFunc("GET /{owner}/{repo}/-/tags/archive", s.tagArchive)
169 mux.HandleFunc("GET /{owner}/{repo}/-/archive/{rev}/{file}", s.commitArchive)
167 170 mux.HandleFunc("GET /{owner}/{repo}/-/commit/{sha}", s.commit)
171 mux.HandleFunc("GET /{owner}/{repo}/-/branches/archive", s.branchArchive)
168 172 mux.HandleFunc("GET /{owner}/{repo}/-/branches", s.branches)
169 173 mux.HandleFunc("POST /{owner}/{repo}/-/branches", s.createBranch)
170 174 mux.HandleFunc("POST /{owner}/{repo}/-/branches/delete", s.deleteBranch)
@@ -197,6 +201,7 @@ func (s *Server) Handler() http.Handler {
197 201 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}", s.showJob)
198 202 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/log", s.jobLog)
199 203 mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/play", s.playJob)
204 mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/retry", s.retryPipeline)
200 205 mux.HandleFunc("GET /{owner}/{repo}/-/ci/editor", s.ciEditor)
201 206 mux.HandleFunc("POST /{owner}/{repo}/-/ci/editor", s.saveCIEditor)
202 207 mux.HandleFunc("POST /{owner}/{repo}/-/ci/lint", s.lintCI)
@@ -254,6 +259,7 @@ func (s *Server) mustTemplates() {
254 259 r, _ := utf8.DecodeRuneInString(s)
255 260 return strings.ToUpper(string(r))
256 261 },
262 "tileHue": tileHue,
257 263 "splitPath": func(p string) []string {
258 264 if p == "" {
259 265 return nil
@@ -279,6 +285,21 @@ func (s *Server) mustTemplates() {
279 285 }
280 286 return label
281 287 },
288 "printf": fmt.Sprintf,
289 "dict": func(kv ...any) (map[string]any, error) {
290 if len(kv)%2 != 0 {
291 return nil, fmt.Errorf("dict")
292 }
293 m := make(map[string]any, len(kv)/2)
294 for i := 0; i < len(kv); i += 2 {
295 key, ok := kv[i].(string)
296 if !ok {
297 return nil, fmt.Errorf("dict")
298 }
299 m[key] = kv[i+1]
300 }
301 return m, nil
302 },
282 303 }).ParseFS(webFS, "templates/*.html"))
283 304 }
284 305 s.tmpl = s.byLang[string(i18n.EN)]
@@ -515,6 +536,9 @@ type View struct {
515 536 CanComment bool
516 537 CanApply bool
517 538 Commits []CommitRow
539 CommitDays []CommitDay
540 CommitPrev string
541 CommitNext string
518 542 Commit *CommitRow
519 543 CommitDiff *CommitDiff
520 544 Entries []EntryRow
@@ -523,8 +547,11 @@ type View struct {
523 547 BlobPath string
524 548 Binary bool
525 549 Branches []BranchRow
550 Branch *BranchBoard
526 551 MRs []store.MergeRequest
552 Flow *FlowBoard
527 553 MR *store.MergeRequest
554 Banner *MRBanner
528 555 MRPipe *PipeRow
529 556 MergeBlocks []string
530 557 Approval *ApprovalView
@@ -546,6 +573,7 @@ type View struct {
546 573 PipeLabel string
547 574 PipeJobs []JobLink
548 575 PipeStages []StageView
576 PipeFailed bool
549 577 Live bool
550 578 LiveURL string
551 579 Jobs []store.Job
@@ -638,6 +666,12 @@ type RepoCard struct {
638 666 When string
639 667 }
640 668
669 // AccountLink is een naam die naar een profiel wijst.
670 type AccountLink struct {
671 Name string
672 URL string
673 }
674
641 675 // ProfileCard is het blok over een gebruiker, boven de activiteitenkalender.
642 676 type ProfileCard struct {
643 677 User store.User
@@ -676,9 +710,9 @@ type DiffLineView struct {
676 710
677 711 // TagRow is één tag op de tagspagina.
678 712 type TagRow struct {
679 Name, Message, SHA, Short, Subject, Date string
680 Annotated, Protected, HasRelease, CanDelete bool
681 ZipURL, TarURL string
713 Name, Message, SHA, Short, Subject, Date, When string
714 Annotated, Protected, HasRelease, CanDelete bool
715 ZipURL, TarURL string
682 716 }
683 717
684 718 // FileRow is een rij in de bestandstabel of de boom.
@@ -702,12 +736,19 @@ type CodeLine struct {
702 736 // Author is de gekoppelde gebruiker, of anders de ruwe git-naam.
703 737 // RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.
704 738 type CommitRow struct {
705 SHA, Short, Author, Date, Subject, Body, When string
706 UserURL, Avatar, Initial, RawName, PushedBy string
707 PipeID int64
708 PipeStatus, PipeLabel, PipeDuration string
709 PipeStages []StageView
710 PipeLive bool
739 SHA, Short, Author, Who, Date, Subject, Body, When string
740 UserURL, WhoURL, Avatar, Initial, RawName, PushedBy string
741 Ident template.HTML
742 PipeID int64
743 PipeStatus, PipeLabel, PipeDuration string
744 PipeStages []StageView
745 PipeLive, PipeFailed bool
746 }
747
748 // CommitDay is één dag op de commitlijst, nieuwste dag eerst.
749 type CommitDay struct {
750 Label string
751 Items []CommitRow
711 752 }
712 753
713 754 // EntryRow is een bestand of map.
@@ -718,13 +759,23 @@ type EntryRow struct {
718 759 // BranchRow is een branch, met of zonder bescherming.
719 760 type BranchRow struct {
720 761 Name, SHA, Short, Subject, When, WhenTitle string
721 Protected, Default bool
762 RepoPath, ZipURL, TarURL string
763 Protected, Default, CanEdit bool
764 Target string
722 765 Ahead, Behind int
766 Unix int64
723 767 PipeID int64
724 768 PipeStatus, PipeLabel string
725 769 OpenMRs []int64
726 770 }
727 771
772 // BranchBoard is de gegroepeerde branches-pagina.
773 type BranchBoard struct {
774 State string
775 ShowActive, ShowStale bool
776 Active, Stale []BranchRow
777 }
778
728 779 // TimelineItem is één gebeurtenis of reactie op een merge request.
729 780 type TimelineItem struct {
730 781 ID int64
@@ -6,6 +6,7 @@ import (
6 "crypto/rand"
6 "crypto/rand"
7 "embed"
7 "embed"
8 "encoding/hex"
8 "encoding/hex"
9 "fmt"
9 "html/template"
10 "html/template"
10 "io/fs"
11 "io/fs"
11 "log/slog"
12 "log/slog"
@@ -106,6 +107,7 @@ func (s *Server) Handler() http.Handler {
106 mux.HandleFunc("POST /settings/ssh/delete", s.deleteSSH)
107 mux.HandleFunc("POST /settings/ssh/delete", s.deleteSSH)
107 mux.HandleFunc("GET /settings/export", s.export)
108 mux.HandleFunc("GET /settings/export", s.export)
108 mux.HandleFunc("GET /users/{username}", s.profile)
109 mux.HandleFunc("GET /users/{username}", s.profile)
110 mux.HandleFunc("GET /{name}", s.userShort)
109 mux.HandleFunc("GET /groups/{path}", s.groupPage)
111 mux.HandleFunc("GET /groups/{path}", s.groupPage)
110 mux.HandleFunc("GET /groups/{path}/logo", s.groupLogo)
112 mux.HandleFunc("GET /groups/{path}/logo", s.groupLogo)
111 mux.HandleFunc("POST /groups/{path}/settings", s.saveGroup)
113 mux.HandleFunc("POST /groups/{path}/settings", s.saveGroup)
@@ -164,7 +166,9 @@ func (s *Server) Handler() http.Handler {
164 mux.HandleFunc("POST /{owner}/{repo}/-/tags", s.createTag)
166 mux.HandleFunc("POST /{owner}/{repo}/-/tags", s.createTag)
165 mux.HandleFunc("POST /{owner}/{repo}/-/tags/delete", s.deleteTag)
167 mux.HandleFunc("POST /{owner}/{repo}/-/tags/delete", s.deleteTag)
166 mux.HandleFunc("GET /{owner}/{repo}/-/tags/archive", s.tagArchive)
168 mux.HandleFunc("GET /{owner}/{repo}/-/tags/archive", s.tagArchive)
169 mux.HandleFunc("GET /{owner}/{repo}/-/archive/{rev}/{file}", s.commitArchive)
167 mux.HandleFunc("GET /{owner}/{repo}/-/commit/{sha}", s.commit)
170 mux.HandleFunc("GET /{owner}/{repo}/-/commit/{sha}", s.commit)
171 mux.HandleFunc("GET /{owner}/{repo}/-/branches/archive", s.branchArchive)
168 mux.HandleFunc("GET /{owner}/{repo}/-/branches", s.branches)
172 mux.HandleFunc("GET /{owner}/{repo}/-/branches", s.branches)
169 mux.HandleFunc("POST /{owner}/{repo}/-/branches", s.createBranch)
173 mux.HandleFunc("POST /{owner}/{repo}/-/branches", s.createBranch)
170 mux.HandleFunc("POST /{owner}/{repo}/-/branches/delete", s.deleteBranch)
174 mux.HandleFunc("POST /{owner}/{repo}/-/branches/delete", s.deleteBranch)
@@ -197,6 +201,7 @@ func (s *Server) Handler() http.Handler {
197 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}", s.showJob)
201 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}", s.showJob)
198 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/log", s.jobLog)
202 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/log", s.jobLog)
199 mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/play", s.playJob)
203 mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/play", s.playJob)
204 mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/retry", s.retryPipeline)
200 mux.HandleFunc("GET /{owner}/{repo}/-/ci/editor", s.ciEditor)
205 mux.HandleFunc("GET /{owner}/{repo}/-/ci/editor", s.ciEditor)
201 mux.HandleFunc("POST /{owner}/{repo}/-/ci/editor", s.saveCIEditor)
206 mux.HandleFunc("POST /{owner}/{repo}/-/ci/editor", s.saveCIEditor)
202 mux.HandleFunc("POST /{owner}/{repo}/-/ci/lint", s.lintCI)
207 mux.HandleFunc("POST /{owner}/{repo}/-/ci/lint", s.lintCI)
@@ -254,6 +259,7 @@ func (s *Server) mustTemplates() {
254 r, _ := utf8.DecodeRuneInString(s)
259 r, _ := utf8.DecodeRuneInString(s)
255 return strings.ToUpper(string(r))
260 return strings.ToUpper(string(r))
256 },
261 },
262 "tileHue": tileHue,
257 "splitPath": func(p string) []string {
263 "splitPath": func(p string) []string {
258 if p == "" {
264 if p == "" {
259 return nil
265 return nil
@@ -279,6 +285,21 @@ func (s *Server) mustTemplates() {
279 }
285 }
280 return label
286 return label
281 },
287 },
288 "printf": fmt.Sprintf,
289 "dict": func(kv ...any) (map[string]any, error) {
290 if len(kv)%2 != 0 {
291 return nil, fmt.Errorf("dict")
292 }
293 m := make(map[string]any, len(kv)/2)
294 for i := 0; i < len(kv); i += 2 {
295 key, ok := kv[i].(string)
296 if !ok {
297 return nil, fmt.Errorf("dict")
298 }
299 m[key] = kv[i+1]
300 }
301 return m, nil
302 },
282 }).ParseFS(webFS, "templates/*.html"))
303 }).ParseFS(webFS, "templates/*.html"))
283 }
304 }
284 s.tmpl = s.byLang[string(i18n.EN)]
305 s.tmpl = s.byLang[string(i18n.EN)]
@@ -515,6 +536,9 @@ type View struct {
515 CanComment bool
536 CanComment bool
516 CanApply bool
537 CanApply bool
517 Commits []CommitRow
538 Commits []CommitRow
539 CommitDays []CommitDay
540 CommitPrev string
541 CommitNext string
518 Commit *CommitRow
542 Commit *CommitRow
519 CommitDiff *CommitDiff
543 CommitDiff *CommitDiff
520 Entries []EntryRow
544 Entries []EntryRow
@@ -523,8 +547,11 @@ type View struct {
523 BlobPath string
547 BlobPath string
524 Binary bool
548 Binary bool
525 Branches []BranchRow
549 Branches []BranchRow
550 Branch *BranchBoard
526 MRs []store.MergeRequest
551 MRs []store.MergeRequest
552 Flow *FlowBoard
527 MR *store.MergeRequest
553 MR *store.MergeRequest
554 Banner *MRBanner
528 MRPipe *PipeRow
555 MRPipe *PipeRow
529 MergeBlocks []string
556 MergeBlocks []string
530 Approval *ApprovalView
557 Approval *ApprovalView
@@ -546,6 +573,7 @@ type View struct {
546 PipeLabel string
573 PipeLabel string
547 PipeJobs []JobLink
574 PipeJobs []JobLink
548 PipeStages []StageView
575 PipeStages []StageView
576 PipeFailed bool
549 Live bool
577 Live bool
550 LiveURL string
578 LiveURL string
551 Jobs []store.Job
579 Jobs []store.Job
@@ -638,6 +666,12 @@ type RepoCard struct {
638 When string
666 When string
639}
667}
640
668
669// AccountLink is een naam die naar een profiel wijst.
670type AccountLink struct {
671 Name string
672 URL string
673}
674
641// ProfileCard is het blok over een gebruiker, boven de activiteitenkalender.
675// ProfileCard is het blok over een gebruiker, boven de activiteitenkalender.
642type ProfileCard struct {
676type ProfileCard struct {
643 User store.User
677 User store.User
@@ -676,9 +710,9 @@ type DiffLineView struct {
676
710
677// TagRow is één tag op de tagspagina.
711// TagRow is één tag op de tagspagina.
678type TagRow struct {
712type TagRow struct {
679 Name, Message, SHA, Short, Subject, Date string
713 Name, Message, SHA, Short, Subject, Date, When string
680 Annotated, Protected, HasRelease, CanDelete bool
714 Annotated, Protected, HasRelease, CanDelete bool
681 ZipURL, TarURL string
715 ZipURL, TarURL string
682}
716}
683
717
684// FileRow is een rij in de bestandstabel of de boom.
718// FileRow is een rij in de bestandstabel of de boom.
@@ -702,12 +736,19 @@ type CodeLine struct {
702// Author is de gekoppelde gebruiker, of anders de ruwe git-naam.
736// Author is de gekoppelde gebruiker, of anders de ruwe git-naam.
703// RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.
737// RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.
704type CommitRow struct {
738type CommitRow struct {
705 SHA, Short, Author, Date, Subject, Body, When string
739 SHA, Short, Author, Who, Date, Subject, Body, When string
706 UserURL, Avatar, Initial, RawName, PushedBy string
740 UserURL, WhoURL, Avatar, Initial, RawName, PushedBy string
707 PipeID int64
741 Ident template.HTML
708 PipeStatus, PipeLabel, PipeDuration string
742 PipeID int64
709 PipeStages []StageView
743 PipeStatus, PipeLabel, PipeDuration string
710 PipeLive bool
744 PipeStages []StageView
745 PipeLive, PipeFailed bool
746}
747
748// CommitDay is één dag op de commitlijst, nieuwste dag eerst.
749type CommitDay struct {
750 Label string
751 Items []CommitRow
711}
752}
712
753
713// EntryRow is een bestand of map.
754// EntryRow is een bestand of map.
@@ -718,13 +759,23 @@ type EntryRow struct {
718// BranchRow is een branch, met of zonder bescherming.
759// BranchRow is een branch, met of zonder bescherming.
719type BranchRow struct {
760type BranchRow struct {
720 Name, SHA, Short, Subject, When, WhenTitle string
761 Name, SHA, Short, Subject, When, WhenTitle string
721 Protected, Default bool
762 RepoPath, ZipURL, TarURL string
763 Protected, Default, CanEdit bool
764 Target string
722 Ahead, Behind int
765 Ahead, Behind int
766 Unix int64
723 PipeID int64
767 PipeID int64
724 PipeStatus, PipeLabel string
768 PipeStatus, PipeLabel string
725 OpenMRs []int64
769 OpenMRs []int64
726}
770}
727
771
772// BranchBoard is de gegroepeerde branches-pagina.
773type BranchBoard struct {
774 State string
775 ShowActive, ShowStale bool
776 Active, Stale []BranchRow
777}
778
728// TimelineItem is één gebeurtenis of reactie op een merge request.
779// TimelineItem is één gebeurtenis of reactie op een merge request.
729type TimelineItem struct {
780type TimelineItem struct {
730 ID int64
781 ID int64
internal/server/server_test.go +2 −0
@@ -542,6 +542,7 @@ func TestProjectOverviewAndFiles(t *testing.T) {
542 542 `data-path="src/main.go"`,
543 543 `data-path="crates/sim"`,
544 544 `data-repo="tim/legacy-cycles"`,
545 `class="fill"`,
545 546 `class="filepane"`,
546 547 `class="twist"`,
547 548 `aria-expanded="false"`,
@@ -574,6 +575,7 @@ func TestProjectOverviewAndFiles(t *testing.T) {
574 575 `aria-expanded="true"`,
575 576 `data-path="src"`,
576 577 `data-repo="tim/legacy-cycles"`,
578 `class="fill"`,
577 579 `class="filepane"`,
578 580 `class="chevron"`,
579 581 `<span class="hl-k">func</span>`,
@@ -542,6 +542,7 @@ func TestProjectOverviewAndFiles(t *testing.T) {
542 `data-path="src/main.go"`,
542 `data-path="src/main.go"`,
543 `data-path="crates/sim"`,
543 `data-path="crates/sim"`,
544 `data-repo="tim/legacy-cycles"`,
544 `data-repo="tim/legacy-cycles"`,
545 `class="fill"`,
545 `class="filepane"`,
546 `class="filepane"`,
546 `class="twist"`,
547 `class="twist"`,
547 `aria-expanded="false"`,
548 `aria-expanded="false"`,
@@ -574,6 +575,7 @@ func TestProjectOverviewAndFiles(t *testing.T) {
574 `aria-expanded="true"`,
575 `aria-expanded="true"`,
575 `data-path="src"`,
576 `data-path="src"`,
576 `data-repo="tim/legacy-cycles"`,
577 `data-repo="tim/legacy-cycles"`,
578 `class="fill"`,
577 `class="filepane"`,
579 `class="filepane"`,
578 `class="chevron"`,
580 `class="chevron"`,
579 `<span class="hl-k">func</span>`,
581 `<span class="hl-k">func</span>`,
internal/server/static/branch.js +7 −0
@@ -53,6 +53,13 @@
53 53 var name = (row.getAttribute("data-name") || "").toLowerCase();
54 54 row.hidden = q !== "" && name.indexOf(q) < 0;
55 55 });
56 document.querySelectorAll("[data-ref-group]").forEach(function (group) {
57 var visible = false;
58 group.querySelectorAll("[data-branch-row]").forEach(function (row) {
59 if (!row.hidden) visible = true;
60 });
61 group.hidden = !visible && group.querySelector("[data-branch-row]");
62 });
56 63 });
57 64 }
58 65 })();
@@ -53,6 +53,13 @@
53 var name = (row.getAttribute("data-name") || "").toLowerCase();
53 var name = (row.getAttribute("data-name") || "").toLowerCase();
54 row.hidden = q !== "" && name.indexOf(q) < 0;
54 row.hidden = q !== "" && name.indexOf(q) < 0;
55 });
55 });
56 document.querySelectorAll("[data-ref-group]").forEach(function (group) {
57 var visible = false;
58 group.querySelectorAll("[data-branch-row]").forEach(function (row) {
59 if (!row.hidden) visible = true;
60 });
61 group.hidden = !visible && group.querySelector("[data-branch-row]");
62 });
56 });
63 });
57 }
64 }
58})();
65})();
internal/server/static/commits.js added +19 −0
@@ -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})();
internal/server/static/pipeline.js +53 −4
@@ -100,12 +100,14 @@
100 100 }
101 101
102 102 var stageSelect = document.querySelector("[data-stage-select]");
103 function applyStage(want) {
104 document.querySelectorAll(".related li").forEach(function (li) {
105 li.hidden = li.getAttribute("data-stage") !== want;
106 });
107 }
103 108 if (stageSelect) {
104 109 stageSelect.addEventListener("change", function () {
105 var want = stageSelect.value;
106 document.querySelectorAll(".related li").forEach(function (li) {
107 li.hidden = li.getAttribute("data-stage") !== want;
108 });
110 applyStage(stageSelect.value);
109 111 });
110 112 }
111 113
@@ -157,6 +159,41 @@
157 159 q.textContent = text;
158 160 }
159 161
162 function jobMarkedFailed(status) {
163 return status === "failed" || status === "warning";
164 }
165
166 function stagesHaveFailure(stages) {
167 var failed = false;
168 (stages || []).forEach(function (st) {
169 (st.jobs || []).forEach(function (job) {
170 if (jobMarkedFailed(job.status)) {
171 failed = true;
172 }
173 });
174 });
175 return failed;
176 }
177
178 function jobsHaveFailure(jobs) {
179 var failed = false;
180 (jobs || []).forEach(function (job) {
181 if (jobMarkedFailed(job.status)) {
182 failed = true;
183 }
184 });
185 return failed;
186 }
187
188 function syncRetry(pipeID, failed) {
189 document.querySelectorAll("[data-retry-failed]").forEach(function (el) {
190 if (pipeID && el.getAttribute("data-pipe") !== String(pipeID)) {
191 return;
192 }
193 el.hidden = !failed;
194 });
195 }
196
160 197 function patchPipeRow(live, row) {
161 198 var status = live.querySelector("[data-pipe-status]");
162 199 if (status) {
@@ -174,6 +211,7 @@
174 211 if (when) {
175 212 when.textContent = row.when || "";
176 213 }
214 syncRetry(live.getAttribute("data-pipe"), stagesHaveFailure(row.stages));
177 215 var stages = live.querySelector(".stages");
178 216 if (!stages) {
179 217 return;
@@ -311,6 +349,14 @@
311 349 if (head) {
312 350 patchPipeRow(head, data);
313 351 }
352 var mr = document.querySelector("[data-mr-pipe]");
353 if (mr) {
354 patchPipeRow(mr, data);
355 }
356 var pipeHead = document.querySelector(".pipehead[data-pipe]");
357 if (pipeHead) {
358 syncRetry(pipeHead.getAttribute("data-pipe"), jobsHaveFailure(data.jobs) || stagesHaveFailure(data.stages));
359 }
314 360 }
315 361
316 362 var liveEl = document.querySelector("[data-live-on]");
@@ -580,6 +626,9 @@
580 626 qEl.textContent = data.queue || "";
581 627 qEl.hidden = !data.queue;
582 628 }
629 if (stageSelect) {
630 applyStage(stageSelect.value);
631 }
583 632 if (data.status === "running" || data.status === "queued") {
584 633 setTimeout(poll, 1500);
585 634 return;
@@ -100,12 +100,14 @@
100 }
100 }
101
101
102 var stageSelect = document.querySelector("[data-stage-select]");
102 var stageSelect = document.querySelector("[data-stage-select]");
103 function applyStage(want) {
104 document.querySelectorAll(".related li").forEach(function (li) {
105 li.hidden = li.getAttribute("data-stage") !== want;
106 });
107 }
103 if (stageSelect) {
108 if (stageSelect) {
104 stageSelect.addEventListener("change", function () {
109 stageSelect.addEventListener("change", function () {
105 var want = stageSelect.value;
110 applyStage(stageSelect.value);
106 document.querySelectorAll(".related li").forEach(function (li) {
107 li.hidden = li.getAttribute("data-stage") !== want;
108 });
109 });
111 });
110 }
112 }
111
113
@@ -157,6 +159,41 @@
157 q.textContent = text;
159 q.textContent = text;
158 }
160 }
159
161
162 function jobMarkedFailed(status) {
163 return status === "failed" || status === "warning";
164 }
165
166 function stagesHaveFailure(stages) {
167 var failed = false;
168 (stages || []).forEach(function (st) {
169 (st.jobs || []).forEach(function (job) {
170 if (jobMarkedFailed(job.status)) {
171 failed = true;
172 }
173 });
174 });
175 return failed;
176 }
177
178 function jobsHaveFailure(jobs) {
179 var failed = false;
180 (jobs || []).forEach(function (job) {
181 if (jobMarkedFailed(job.status)) {
182 failed = true;
183 }
184 });
185 return failed;
186 }
187
188 function syncRetry(pipeID, failed) {
189 document.querySelectorAll("[data-retry-failed]").forEach(function (el) {
190 if (pipeID && el.getAttribute("data-pipe") !== String(pipeID)) {
191 return;
192 }
193 el.hidden = !failed;
194 });
195 }
196
160 function patchPipeRow(live, row) {
197 function patchPipeRow(live, row) {
161 var status = live.querySelector("[data-pipe-status]");
198 var status = live.querySelector("[data-pipe-status]");
162 if (status) {
199 if (status) {
@@ -174,6 +211,7 @@
174 if (when) {
211 if (when) {
175 when.textContent = row.when || "";
212 when.textContent = row.when || "";
176 }
213 }
214 syncRetry(live.getAttribute("data-pipe"), stagesHaveFailure(row.stages));
177 var stages = live.querySelector(".stages");
215 var stages = live.querySelector(".stages");
178 if (!stages) {
216 if (!stages) {
179 return;
217 return;
@@ -311,6 +349,14 @@
311 if (head) {
349 if (head) {
312 patchPipeRow(head, data);
350 patchPipeRow(head, data);
313 }
351 }
352 var mr = document.querySelector("[data-mr-pipe]");
353 if (mr) {
354 patchPipeRow(mr, data);
355 }
356 var pipeHead = document.querySelector(".pipehead[data-pipe]");
357 if (pipeHead) {
358 syncRetry(pipeHead.getAttribute("data-pipe"), jobsHaveFailure(data.jobs) || stagesHaveFailure(data.stages));
359 }
314 }
360 }
315
361
316 var liveEl = document.querySelector("[data-live-on]");
362 var liveEl = document.querySelector("[data-live-on]");
@@ -580,6 +626,9 @@
580 qEl.textContent = data.queue || "";
626 qEl.textContent = data.queue || "";
581 qEl.hidden = !data.queue;
627 qEl.hidden = !data.queue;
582 }
628 }
629 if (stageSelect) {
630 applyStage(stageSelect.value);
631 }
583 if (data.status === "running" || data.status === "queued") {
632 if (data.status === "running" || data.status === "queued") {
584 setTimeout(poll, 1500);
633 setTimeout(poll, 1500);
585 return;
634 return;
internal/server/static/repo.js +1 −0
@@ -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 });
internal/server/static/style.css +344 −11
@@ -183,8 +183,18 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
183 183 .projhead h1 { margin: 0; font-size: var(--fs-h); }
184 184 .tile {
185 185 width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center;
186 background: #e56a93; color: white; font-weight: 700; font-size: 1.2rem;
187 }
186 background: #e56a93; color: white; font-weight: 700; font-size: 1.2rem; flex: none;
187 }
188 .tile.hue0, .avatar.hue0 { background: #c0392b; }
189 .tile.hue1, .avatar.hue1 { background: #d35400; }
190 .tile.hue2, .avatar.hue2 { background: #1f6b3a; }
191 .tile.hue3, .avatar.hue3 { background: #1f6feb; }
192 .tile.hue4, .avatar.hue4 { background: #6f42c1; }
193 .tile.hue5, .avatar.hue5 { background: #0e7490; }
194 .tile.hue6, .avatar.hue6 { background: #9a3412; }
195 .tile.hue7, .avatar.hue7 { background: #9d174d; }
196 .avatar.hue0, .avatar.hue1, .avatar.hue2, .avatar.hue3,
197 .avatar.hue4, .avatar.hue5, .avatar.hue6, .avatar.hue7 { color: #fff; }
188 198 .vis { width: 18px; height: 18px; color: var(--muted); }
189 199 .ficon { width: 16px; height: 16px; vertical-align: -2px; margin-right: 0.25rem; }
190 200 .proj { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.2rem; align-items: start; }
@@ -234,7 +244,72 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
234 244 width: 32px; height: 32px; border-radius: 50%; background: #d5e0ee; color: var(--ink);
235 245 display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; flex: none;
236 246 }
237 img.avatar { object-fit: cover; display: block; }
247 img.avatar, svg.avatar.ident { object-fit: cover; display: block; }
248 .clogref { display: flex; align-items: center; gap: 0.7rem; margin: 0 0 0.35rem; }
249 .clogpick {
250 display: inline-flex; align-items: center; gap: 0.35rem;
251 border: 1px solid var(--line); border-radius: 8px; background: white;
252 padding: 0 0.45rem 0 0.55rem; min-height: 32px;
253 }
254 .clogpick select {
255 border: 0; background: transparent; min-height: 30px; width: auto;
256 padding: 0 1.1rem 0 0; font: inherit;
257 }
258 .clogrepo { font-weight: 650; color: var(--ink); text-decoration: none; }
259 .clog h1 { margin: 0.15rem 0 0.75rem; font-size: 1.7rem; }
260 .clogsearch {
261 display: flex; align-items: center; gap: 0.4rem; margin: 0 0 1rem;
262 border: 1px solid var(--line); border-radius: 8px; background: white;
263 min-height: 36px; padding: 0 0.55rem;
264 }
265 .clogsearch input { border: 0; flex: 1; min-height: 0; padding: 0; background: transparent; width: auto; }
266 .clogsearch input:focus { outline: none; }
267 .clogsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
268 .clogsearch button { background: transparent; color: var(--muted); border: 0; min-height: 0; width: 28px; padding: 0; }
269 .cday { position: relative; margin: 0 0 0.35rem; padding-left: 1.35rem; }
270 .cday::before {
271 content: ""; position: absolute; left: 0.22rem; top: 0.7rem; bottom: 0.2rem;
272 width: 2px; background: #d8dee6;
273 }
274 .cday h2 { position: relative; margin: 0.35rem 0 0.55rem; font-size: 0.95rem; }
275 .cday h2::before {
276 content: ""; position: absolute; left: -1.28rem; top: 0.28rem;
277 width: 10px; height: 10px; border-radius: 50%; background: white;
278 box-shadow: inset 0 0 0 2px #8b95a1;
279 }
280 .ccard {
281 display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem;
282 background: white; border: 1px solid var(--line); border-radius: 10px;
283 padding: 0.65rem 0.8rem; margin: 0 0 0.55rem;
284 }
285 .cmain { flex: 1; min-width: 0; }
286 .csubject { display: block; font-weight: 700; color: var(--ink); text-decoration: none; }
287 .csubject:hover { color: var(--blue-deep); }
288 .cby { margin: 0.12rem 0 0; color: var(--muted); font-size: var(--fs-sm); }
289 .cby a { color: inherit; }
290 .cacts { display: flex; align-items: center; gap: 0.3rem; flex: none; }
291 .cacts code { font-family: var(--mono); color: var(--muted); font-size: 0.85rem; }
292 a.status.markonly { padding: 0; background: transparent; min-height: 0; }
293 .cchev::before {
294 content: ""; width: 0.38rem; height: 0.38rem;
295 border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
296 transform: translateY(-1px) rotate(45deg);
297 }
298 .cchev.open::before { transform: translateY(1px) rotate(225deg); }
299 .cmsg {
300 flex-basis: 100%; margin: 0.15rem 0 0; padding-top: 0.45rem;
301 border-top: 1px solid var(--line); white-space: pre-wrap;
302 }
303 .cmsg[hidden] { display: none !important; }
304 .clogmore { display: flex; gap: 0.6rem; margin: 0.4rem 0 0.6rem; }
305 .clogmore a {
306 display: inline-flex; align-items: center; min-height: var(--control-h);
307 padding: 0 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);
308 background: white; color: var(--ink); text-decoration: none;
309 }
310 @media (max-width: 800px) {
311 .cacts { width: 100%; justify-content: flex-end; }
312 }
238 313 .avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; }
239 314 .avatar.xl { width: 96px; height: 96px; font-size: 2rem; }
240 315 a.avatarlink { display: inline-grid; color: inherit; text-decoration: none; line-height: 0; }
@@ -279,9 +354,28 @@ table.md th, table.md td { border: 1px solid var(--line); padding: 0.4rem 0.6rem
279 354 .counts a { text-decoration: none; }
280 355 .fileview {
281 356 display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: stretch;
282 /* topbalk, padding van main, kruimels en paginatitel */
283 height: calc(100vh - var(--top-h) - 8.25rem); min-height: 18rem;
284 }
357 min-width: 0; min-height: 0;
358 }
359 body:has(main.fill) { height: 100vh; overflow: hidden; }
360 .frame.with-side:has(main.fill) {
361 height: calc(100vh - var(--top-h));
362 overflow: hidden;
363 align-items: stretch;
364 }
365 .content:has(main.fill) {
366 flex: 1 1 auto; align-self: stretch; min-width: 0; min-height: 0;
367 overflow: hidden; align-items: stretch; justify-content: stretch;
368 }
369 main.fill {
370 flex: 1 1 auto; width: 100%; max-width: none; height: 100%;
371 min-width: 0; min-height: 0; box-sizing: border-box;
372 display: flex; flex-direction: column; overflow: hidden;
373 padding-bottom: var(--sp-3);
374 }
375 main.fill > .crumbs,
376 main.fill > .pagehead,
377 main.fill > .flash { flex: none; }
378 main.fill > .fileview { flex: 1 1 auto; min-height: 0; }
285 379 .treebox { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
286 380 .treebox h2 { margin: 0 0 0.5rem; font-size: 1.15rem; flex: none; }
287 381 .treebox > input { flex: none; }
@@ -313,13 +407,20 @@ table.md th, table.md td { border: 1px solid var(--line); padding: 0.4rem 0.6rem
313 407 .treelist li.depth-6, .treelist li.depth-7, .treelist li.depth-8 { padding-left: 4.4rem; }
314 408 .filecol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
315 409 .filecol > .toolbar { flex: none; margin-top: 0; }
316 .filepane { flex: 1 1 auto; min-height: 0; overflow: auto; }
410 .filepane { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; }
411 .filepane:has(.codebox) { display: flex; flex-direction: column; overflow: hidden; }
412 .filepane:has(.codebox) > .filename,
413 .filepane:has(.codebox) > .commitbar { flex: none; }
317 414 .filename { display: flex; align-items: center; gap: 0.35rem; margin: 0.2rem 0 0.6rem; }
318 415 .codebox { margin-top: 0.8rem; overflow: auto; }
319 .fileview .codebox { overflow: visible; }
416 .fileview .codebox {
417 overflow: auto; flex: 1 1 auto; min-height: 0; min-width: 0; margin-top: 0;
418 }
320 419 table.code { border-collapse: collapse; width: 100%; }
420 .fileview table.code { width: max-content; min-width: 100%; }
321 421 table.code td { border: 0; padding: 0 0.7rem; vertical-align: top; font-family: ui-monospace, monospace; font-size: 0.86rem; line-height: 1.45; }
322 422 table.code td.ln { color: #8c959f; text-align: right; width: 1%; user-select: none; background: #f6f8fa; }
423 .fileview table.code td.ln { position: sticky; left: 0; z-index: 1; }
323 424 table.code td.src { white-space: pre; }
324 425 .hl-k { color: #8250df; }
325 426 .hl-s { color: #cf222e; }
@@ -384,6 +485,14 @@ table.code td.src { white-space: pre; }
384 485 }
385 486 .repolist { list-style: none; padding: 0; margin: .4rem 0 1rem; }
386 487 .repolist > li { display: flex; align-items: center; gap: .7rem; padding: .75rem .2rem; border-bottom: 1px solid var(--line); }
488 .repolist .tile, .repolist .avatar { width: 32px; height: 32px; font-size: .9rem; }
489 .repolist form { margin: 0; }
490 .picklist { border: 1px solid var(--line); border-radius: 10px; margin: .35rem 0 .8rem; padding: .35rem; }
491 .picklist legend { padding: 0 .25rem; color: var(--muted); font-size: var(--fs-sm); }
492 .picklist label, label.pickrow { display: flex; align-items: center; gap: .55rem; padding: .35rem .45rem; border-radius: 8px; cursor: pointer; }
493 .picklist label:has(input:checked) { background: #eef4ff; }
494 .picklist input, label.pickrow input { margin: 0; }
495 .picklist .tile, .picklist .avatar, label.pickrow .avatar { width: 24px; height: 24px; font-size: .75rem; }
387 496 .reponame { font-weight: 600; text-decoration: none; }
388 497 .stars { color: #9a6700; white-space: nowrap; }
389 498 .grown { flex: 1; }
@@ -393,6 +502,24 @@ table.code td.src { white-space: pre; }
393 502 .rowmenu .menu-panel { position: absolute; right: 0; z-index: 3; min-width: 9rem; }
394 503 .rowmenu .menu-panel button, .rowmenu .menu-panel form { width: 100%; }
395 504 .rowmenu .menu-panel button { text-align: left; border-radius: 8px; }
505 details.piperetry { display: inline-block; vertical-align: middle; flex: none; }
506 .stagecell { display: flex; align-items: center; gap: .45rem; }
507 .pipehead { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
508 .menu-panel.piperetry { min-width: 14rem; padding: .3rem; }
509 .menu-panel.piperetry[popover]:popover-open {
510 width: max-content;
511 min-width: 14rem;
512 max-width: min(18rem, calc(100vw - 16px));
513 padding: .3rem;
514 }
515 .menu-panel.piperetry form { margin: 0; }
516 .menu-panel.piperetry form[hidden] { display: none !important; }
517 .menu-panel.piperetry button {
518 display: block; width: 100%; text-align: left; background: transparent; border: 0;
519 border-radius: 8px; padding: .45rem .6rem; cursor: pointer; font: inherit; color: inherit;
520 white-space: nowrap;
521 }
522 .menu-panel.piperetry button:hover { background: #f3f6fb; }
396 523 img.tile { object-fit: cover; background: #fff; }
397 524 @font-face {
398 525 font-family: "Noto Sans Cuneiform";
@@ -674,6 +801,7 @@ button.section-toggle {
674 801 .jobside h2 { font-size: 0.95rem; margin: 0.9rem 0 0.3rem; }
675 802 .related { list-style: none; margin: 0; padding: 0; }
676 803 .related li { display: flex; align-items: center; gap: 0.3rem; }
804 .related li[hidden] { display: none !important; }
677 805 .related .arrow { width: 1rem; color: var(--muted); }
678 806 .editorhead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.7rem; }
679 807 .editorhead h2 { margin: 0; font-size: 1.15rem; }
@@ -848,6 +976,76 @@ a.btn { text-decoration: none; }
848 976 text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
849 977 }
850 978 .when-short { white-space: nowrap; }
979 .refhead {
980 display: flex; align-items: center; justify-content: space-between;
981 gap: var(--sp-3); flex-wrap: wrap; margin: 0 0 var(--sp-3);
982 }
983 .refhead h1 { margin: 0; }
984 .refhead > button { margin-left: auto; }
985 .reftabs { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: flex-end; min-width: 0; border-bottom: 1px solid var(--line); }
986 .reftabs a {
987 text-decoration: none; color: var(--muted); font-weight: 500;
988 padding: 0.45rem 0; margin-bottom: -1px; border-bottom: 2px solid transparent;
989 }
990 .reftabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
991 .refsearch {
992 display: flex; align-items: center; gap: 0.4rem; margin: 0 0 var(--sp-3);
993 border: 1px solid var(--line); border-radius: var(--radius); background: white;
994 min-height: var(--control-h); padding: 0 0.55rem;
995 }
996 .refsearch input { border: 0; min-height: 0; padding: 0; background: transparent; flex: 1; width: auto; }
997 .refsearch input:focus { outline: none; }
998 .refsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
999 .refsearch button.refgo {
1000 background: transparent; color: var(--muted); border: 0; min-height: 0; width: 28px; padding: 0;
1001 }
1002 .refgroup {
1003 background: #f4f1f8; border: 1px solid #e4dfeb; border-radius: var(--radius-lg);
1004 padding: 0.35rem 0.85rem 0.7rem; margin: 0 0 var(--sp-4);
1005 }
1006 .refgroup h2 { margin: 0.55rem 0.2rem; font-size: 0.95rem; }
1007 .refrow {
1008 display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
1009 background: white; border: 1px solid var(--line); border-radius: var(--radius-lg);
1010 padding: 0.7rem 0.85rem; margin: 0.45rem 0;
1011 }
1012 .refrow[hidden], .refgroup[hidden] { display: none !important; }
1013 .refmain { min-width: 0; }
1014 .refname { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
1015 .refname a { color: var(--ink); text-decoration: none; font-weight: 650; }
1016 .refname code, .refname a code { font-family: var(--mono); font-size: 0.95rem; }
1017 .refcopy { min-height: 24px; width: 24px; padding: 0; }
1018 .refbadge { text-transform: lowercase; background: #eef1f4; color: #57606a; border-color: transparent; }
1019 .refbadge.def { background: var(--blue-soft); color: var(--blue-deep); }
1020 .refmeta {
1021 margin: 0.28rem 0 0; color: var(--muted); font-size: var(--fs-sm);
1022 display: flex; flex-wrap: wrap; gap: 0.35rem 0.55rem; align-items: center;
1023 }
1024 .refmeta a { color: inherit; }
1025 .refdot { color: var(--muted); }
1026 .refsubject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36rem; }
1027 .refnote { margin: 0.35rem 0 0; white-space: pre-wrap; }
1028 .refacts { display: flex; align-items: center; gap: 0.35rem; flex: none; }
1029 .refacts .tiny {
1030 min-height: 1.7rem; padding: 0 0.45rem; font-size: var(--fs-sm);
1031 background: white; color: var(--ink); border: 1px solid var(--line);
1032 border-radius: var(--radius); text-decoration: none; line-height: 1.2;
1033 }
1034 .refacts .rowmenu > summary { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; min-height: 2rem; }
1035 .refdlbtn::after {
1036 content: ""; width: 0.32rem; height: 0.32rem; margin-left: 0.2rem;
1037 border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
1038 transform: translateY(-1px) rotate(45deg);
1039 }
1040 .menu-panel.refdl a { display: block; padding: 0.4rem 0.15rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
1041 .menu-panel.refdl[popover]:popover-open { width: max-content; min-width: 8.5rem; max-width: 14rem; padding: 0.35rem 0.9rem; }
1042 .rowmenu .menu-panel a { display: block; padding: 0.35rem 0.2rem; text-decoration: none; color: var(--ink); }
1043 .refempty { margin: 0.4rem 0.2rem 0.6rem; }
1044 @media (max-width: 800px) {
1045 .refrow { flex-direction: column; }
1046 .refacts { flex-wrap: wrap; }
1047 .refsubject { max-width: 100%; }
1048 }
851 1049 .mergewhy {
852 1050 border: 1px solid var(--line); border-radius: var(--radius);
853 1051 padding: 0.7rem 0.9rem; margin: 0.6rem 0; background: #fff8f0;
@@ -945,10 +1143,15 @@ form.wh .grid-2 label { margin-top: 0; }
945 1143 @media (max-width: 800px) {
946 1144 .proj, .fileview, .joblayout { grid-template-columns: minmax(0, 1fr); }
947 1145 .proj > *, .fileview > *, .toolbar, .commitbar, .hscroll { min-width: 0; max-width: 100%; }
1146 body:has(main.fill) { height: auto; overflow: auto; }
1147 .frame.with-side:has(main.fill),
1148 .content:has(main.fill) { height: auto; overflow: visible; }
1149 main.fill { display: block; height: auto; overflow: visible; }
948 1150 .fileview { height: auto; min-height: 0; }
949 .fileview .treelist { max-height: 40vh; flex: none; }
950 .fileview .filepane { overflow: visible; }
951 .fileview .codebox { overflow: auto; }
1151 .fileview .treelist { max-height: none; overflow: visible; flex: none; }
1152 .fileview .filepane,
1153 .filepane:has(.codebox) { overflow: visible; display: block; }
1154 .fileview .codebox { overflow: auto; flex: none; max-height: none; }
952 1155 .heat-foot { flex-direction: column; align-items: flex-start; }
953 1156 .heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }
954 1157 .repolist > li { flex-wrap: wrap; }
@@ -956,12 +1159,142 @@ form.wh .grid-2 label { margin-top: 0; }
956 1159 .usercard-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
957 1160 .pagehead { align-items: flex-start; }
958 1161 .pageacts { flex-wrap: wrap; justify-content: flex-end; }
1162 .mrwidget .rowline { align-items: flex-start; }
1163 .sub { flex-wrap: nowrap; overflow-x: auto; }
959 1164 }
960 1165 .issuelist { list-style: none; margin: 0; padding: 0; }
961 1166 .issuelist > li { border-bottom: 1px solid var(--line); padding: 0.6rem 0; min-height: 2.4rem; }
1167 .flowhead {
1168 display: flex; align-items: center; justify-content: space-between;
1169 gap: var(--sp-3); flex-wrap: wrap; margin: 0 0 var(--sp-3);
1170 }
1171 .flowtabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; min-width: 0; }
1172 .flowtabs a {
1173 display: inline-flex; align-items: center; gap: 0.35rem;
1174 text-decoration: none; color: var(--ink); font-weight: 500;
1175 padding: 0.35rem 0.65rem; border: 1px solid transparent; border-radius: var(--radius);
1176 }
1177 .flowtabs a.on { background: #f4f7fb; border-color: var(--line); }
1178 .flowcount {
1179 display: inline-block; min-width: 1.15rem; padding: 0 0.35rem; text-align: center;
1180 background: #eef2f6; color: var(--muted); border-radius: 999px; font-size: 0.78rem; font-weight: 650;
1181 }
1182 .flowtabs a.on .flowcount { background: var(--blue-soft); color: var(--blue-deep); }
1183 .flowbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin: 0 0 var(--sp-2); }
1184 .flowsearch {
1185 position: relative;
1186 flex: 1 1 16rem; display: flex; align-items: center; gap: 0.4rem; min-width: 0;
1187 border: 1px solid var(--line); border-radius: var(--radius); background: white;
1188 min-height: var(--control-h); padding: 0 0.35rem 0 0.55rem; color: var(--muted);
1189 }
1190 .flowsearch input { border: 0; min-height: 0; padding: 0; background: transparent; flex: 1; width: auto; color: var(--ink); }
1191 .flowsearch input:focus { outline: none; }
1192 .flowsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
1193 .flowsearch button.flowgo {
1194 position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
1195 clip: rect(0, 0, 0, 0); border: 0; background: transparent; color: transparent;
1196 }
1197 .flowbar > select { width: auto; flex: 0 1 12rem; }
1198 a.flowdir { width: var(--control-h); min-width: var(--control-h); padding: 0; }
1199 .flowlist { list-style: none; margin: 0; padding: 0; }
1200 .flowrow {
1201 display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4);
1202 padding: 0.85rem 0.15rem; border-bottom: 1px solid var(--line);
1203 }
1204 .flowrow:first-child { border-top: 1px solid var(--line); }
1205 .flowmain { min-width: 0; }
1206 .flowtitle { color: inherit; text-decoration: none; font-size: 1rem; line-height: 1.35; }
1207 .flowtitle strong { font-weight: 650; }
1208 .flowtitle:hover strong { text-decoration: underline; }
1209 .flowdraft { color: var(--muted); font-weight: 500; }
1210 .flowmeta {
1211 margin: 0.28rem 0 0; color: var(--muted); font-size: var(--fs-sm);
1212 display: flex; flex-wrap: wrap; gap: 0.35rem 0.45rem; align-items: center;
1213 }
1214 .flowmeta a { color: inherit; }
1215 .flowdot { color: var(--line); }
1216 .flowtarget {
1217 border: 1px solid var(--line); border-radius: 999px; padding: 0 0.4rem;
1218 background: white; color: var(--ink);
1219 }
1220 .flowcomments { display: inline-flex; align-items: center; gap: 0.2rem; }
1221 a.flowpipe { padding: 0; background: transparent; min-height: 0; line-height: 0; }
1222 a.flowpipe .mark { width: 14px; height: 14px; }
1223 a.flowpipe.passed .mark::after { left: 4px; top: 2px; width: 3px; height: 6px; }
1224 .flowside { display: flex; flex-direction: column; align-items: flex-end; gap: 0.28rem; flex: none; text-align: right; }
1225 .flowbadge {
1226 display: inline-block; border-radius: 999px; padding: 0.08rem 0.55rem;
1227 font-size: 0.78rem; font-weight: 650; background: #e5f6ec; color: #146c43;
1228 }
1229 .flowbadge.merged { background: var(--blue-soft); color: var(--blue-deep); }
1230 .flowbadge.closed { background: #fde8e8; color: var(--bad); }
1231 .flowupdated { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
1232 .flowempty { padding: 0.8rem 0; }
1233 @media (max-width: 800px) {
1234 .flowrow { flex-direction: column; gap: 0.4rem; }
1235 .flowside { flex-direction: row; align-items: center; }
1236 .flowbar > select { flex: 1 1 8rem; }
1237 }
962 1238 .lab { display: inline-block; color: #fff; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.78rem; margin: 0 0.2rem; }
963 1239 .issue-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }
964 1240 .checks label { display: block; margin: 0.2rem 0; }
1241 .mrhead { margin: 0 0 var(--sp-4); }
1242 .mrhead h1 { margin: 0.35rem 0 0.15rem; overflow-wrap: anywhere; }
1243 .mrbadges { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0; }
1244 .mrstate {
1245 display: inline-flex; align-items: center; border-radius: 999px;
1246 padding: 0.18rem 0.7rem; font-weight: 650; font-size: 0.84rem;
1247 }
1248 .mrstate.open { background: #e5f6ec; color: #146c43; }
1249 .mrstate.merged { background: var(--blue-soft); color: var(--blue-deep); }
1250 .mrstate.closed { background: #fde8e8; color: var(--bad); }
1251 .mrmeta { color: var(--muted); margin: 0.15rem 0 0.45rem; }
1252 .mrwant { margin: 0.2rem 0; line-height: 1.9; }
1253 .mrwant span:empty { display: none; }
1254 .mrwant a.who {
1255 display: inline-flex; align-items: center; gap: 0.35rem; vertical-align: middle;
1256 margin-right: 0.15rem; font-weight: 650; color: var(--ink); text-decoration: none;
1257 }
1258 .mrwant a.who:hover { text-decoration: underline; }
1259 .branchchip {
1260 display: inline-flex; align-items: center; gap: 0.1rem; max-width: 100%;
1261 background: #f6f8fa; border: 1px solid var(--line); border-radius: 6px;
1262 padding: 0 0.1rem 0 0.4rem; vertical-align: middle;
1263 }
1264 .branchchip code { font-size: 0.85rem; overflow-wrap: anywhere; }
1265 .branchchip button.copy {
1266 border: 0; background: transparent; color: var(--muted); cursor: pointer;
1267 font: inherit; font-size: 0.78rem; min-height: 1.6rem; padding: 0 0.4rem;
1268 }
1269 .mrchips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.35rem 0 0; }
1270 .mrwidget {
1271 background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
1272 margin: var(--sp-3) 0 var(--sp-4);
1273 }
1274 .mrwidget .rowline {
1275 display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem;
1276 padding: 0.75rem 1rem; border-bottom: 1px solid var(--line);
1277 }
1278 .mrwidget .rowline:last-child { border-bottom: 0; }
1279 .mrwidget h2 { margin: 0; font-size: 0.95rem; flex: none; }
1280 .mrwidget .mrpipe { margin: 0; min-width: 0; }
1281 .mrwidget .checks { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; align-items: center; }
1282 .mrwidget .checks label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; }
1283 .mrwidget .checks label:last-child { flex: 1 1 100%; display: block; }
1284 .mrwidget textarea { min-height: 4.5rem; }
1285 .mrwidget form { margin: 0; }
1286 .revblock { flex: 1 1 16rem; min-width: 0; }
1287 .mrreviews { list-style: none; padding: 0; margin: 0 0 0.35rem; }
1288 .mrreviews li { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; padding: 0.15rem 0; }
1289 .mrreviews form { margin: 0; }
1290 .mergeacts { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
1291 .mergedby { margin: 0; }
1292 .mergedby .branchchip { margin-left: 0.45rem; vertical-align: middle; }
1293 .sub .count {
1294 display: inline-block; margin-left: 0.3rem; background: #eef2f7; color: var(--muted);
1295 border-radius: 999px; padding: 0 0.4rem; font-size: 0.75rem; font-weight: 650;
1296 }
1297 .sub a.on .count { background: #fff; color: var(--blue-deep); }
965 1298 .taskcount { margin: 0.7rem 0 0.2rem; font-size: 0.9rem; }
966 1299 ul.tasks { list-style: none; padding-left: 0.1rem; }
967 1300 ul.tasks > li { display: flex; align-items: flex-start; gap: 0.35rem; margin: 0.25rem 0; }
@@ -183,8 +183,18 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
183.projhead h1 { margin: 0; font-size: var(--fs-h); }
183.projhead h1 { margin: 0; font-size: var(--fs-h); }
184.tile {
184.tile {
185 width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center;
185 width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center;
186 background: #e56a93; color: white; font-weight: 700; font-size: 1.2rem;
186 background: #e56a93; color: white; font-weight: 700; font-size: 1.2rem; flex: none;
187}
187}
188.tile.hue0, .avatar.hue0 { background: #c0392b; }
189.tile.hue1, .avatar.hue1 { background: #d35400; }
190.tile.hue2, .avatar.hue2 { background: #1f6b3a; }
191.tile.hue3, .avatar.hue3 { background: #1f6feb; }
192.tile.hue4, .avatar.hue4 { background: #6f42c1; }
193.tile.hue5, .avatar.hue5 { background: #0e7490; }
194.tile.hue6, .avatar.hue6 { background: #9a3412; }
195.tile.hue7, .avatar.hue7 { background: #9d174d; }
196.avatar.hue0, .avatar.hue1, .avatar.hue2, .avatar.hue3,
197.avatar.hue4, .avatar.hue5, .avatar.hue6, .avatar.hue7 { color: #fff; }
188.vis { width: 18px; height: 18px; color: var(--muted); }
198.vis { width: 18px; height: 18px; color: var(--muted); }
189.ficon { width: 16px; height: 16px; vertical-align: -2px; margin-right: 0.25rem; }
199.ficon { width: 16px; height: 16px; vertical-align: -2px; margin-right: 0.25rem; }
190.proj { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.2rem; align-items: start; }
200.proj { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.2rem; align-items: start; }
@@ -234,7 +244,72 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
234 width: 32px; height: 32px; border-radius: 50%; background: #d5e0ee; color: var(--ink);
244 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;
245 display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; flex: none;
236}
246}
237img.avatar { object-fit: cover; display: block; }
247img.avatar, svg.avatar.ident { object-fit: cover; display: block; }
248.clogref { display: flex; align-items: center; gap: 0.7rem; margin: 0 0 0.35rem; }
249.clogpick {
250 display: inline-flex; align-items: center; gap: 0.35rem;
251 border: 1px solid var(--line); border-radius: 8px; background: white;
252 padding: 0 0.45rem 0 0.55rem; min-height: 32px;
253}
254.clogpick select {
255 border: 0; background: transparent; min-height: 30px; width: auto;
256 padding: 0 1.1rem 0 0; font: inherit;
257}
258.clogrepo { font-weight: 650; color: var(--ink); text-decoration: none; }
259.clog h1 { margin: 0.15rem 0 0.75rem; font-size: 1.7rem; }
260.clogsearch {
261 display: flex; align-items: center; gap: 0.4rem; margin: 0 0 1rem;
262 border: 1px solid var(--line); border-radius: 8px; background: white;
263 min-height: 36px; padding: 0 0.55rem;
264}
265.clogsearch input { border: 0; flex: 1; min-height: 0; padding: 0; background: transparent; width: auto; }
266.clogsearch input:focus { outline: none; }
267.clogsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
268.clogsearch button { background: transparent; color: var(--muted); border: 0; min-height: 0; width: 28px; padding: 0; }
269.cday { position: relative; margin: 0 0 0.35rem; padding-left: 1.35rem; }
270.cday::before {
271 content: ""; position: absolute; left: 0.22rem; top: 0.7rem; bottom: 0.2rem;
272 width: 2px; background: #d8dee6;
273}
274.cday h2 { position: relative; margin: 0.35rem 0 0.55rem; font-size: 0.95rem; }
275.cday h2::before {
276 content: ""; position: absolute; left: -1.28rem; top: 0.28rem;
277 width: 10px; height: 10px; border-radius: 50%; background: white;
278 box-shadow: inset 0 0 0 2px #8b95a1;
279}
280.ccard {
281 display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem;
282 background: white; border: 1px solid var(--line); border-radius: 10px;
283 padding: 0.65rem 0.8rem; margin: 0 0 0.55rem;
284}
285.cmain { flex: 1; min-width: 0; }
286.csubject { display: block; font-weight: 700; color: var(--ink); text-decoration: none; }
287.csubject:hover { color: var(--blue-deep); }
288.cby { margin: 0.12rem 0 0; color: var(--muted); font-size: var(--fs-sm); }
289.cby a { color: inherit; }
290.cacts { display: flex; align-items: center; gap: 0.3rem; flex: none; }
291.cacts code { font-family: var(--mono); color: var(--muted); font-size: 0.85rem; }
292a.status.markonly { padding: 0; background: transparent; min-height: 0; }
293.cchev::before {
294 content: ""; width: 0.38rem; height: 0.38rem;
295 border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
296 transform: translateY(-1px) rotate(45deg);
297}
298.cchev.open::before { transform: translateY(1px) rotate(225deg); }
299.cmsg {
300 flex-basis: 100%; margin: 0.15rem 0 0; padding-top: 0.45rem;
301 border-top: 1px solid var(--line); white-space: pre-wrap;
302}
303.cmsg[hidden] { display: none !important; }
304.clogmore { display: flex; gap: 0.6rem; margin: 0.4rem 0 0.6rem; }
305.clogmore a {
306 display: inline-flex; align-items: center; min-height: var(--control-h);
307 padding: 0 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);
308 background: white; color: var(--ink); text-decoration: none;
309}
310@media (max-width: 800px) {
311 .cacts { width: 100%; justify-content: flex-end; }
312}
238.avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; }
313.avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; }
239.avatar.xl { width: 96px; height: 96px; font-size: 2rem; }
314.avatar.xl { width: 96px; height: 96px; font-size: 2rem; }
240a.avatarlink { display: inline-grid; color: inherit; text-decoration: none; line-height: 0; }
315a.avatarlink { display: inline-grid; color: inherit; text-decoration: none; line-height: 0; }
@@ -279,9 +354,28 @@ table.md th, table.md td { border: 1px solid var(--line); padding: 0.4rem 0.6rem
279.counts a { text-decoration: none; }
354.counts a { text-decoration: none; }
280.fileview {
355.fileview {
281 display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: stretch;
356 display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: stretch;
282 /* topbalk, padding van main, kruimels en paginatitel */
357 min-width: 0; min-height: 0;
283 height: calc(100vh - var(--top-h) - 8.25rem); min-height: 18rem;
358}
284}
359body:has(main.fill) { height: 100vh; overflow: hidden; }
360.frame.with-side:has(main.fill) {
361 height: calc(100vh - var(--top-h));
362 overflow: hidden;
363 align-items: stretch;
364}
365.content:has(main.fill) {
366 flex: 1 1 auto; align-self: stretch; min-width: 0; min-height: 0;
367 overflow: hidden; align-items: stretch; justify-content: stretch;
368}
369main.fill {
370 flex: 1 1 auto; width: 100%; max-width: none; height: 100%;
371 min-width: 0; min-height: 0; box-sizing: border-box;
372 display: flex; flex-direction: column; overflow: hidden;
373 padding-bottom: var(--sp-3);
374}
375main.fill > .crumbs,
376main.fill > .pagehead,
377main.fill > .flash { flex: none; }
378main.fill > .fileview { flex: 1 1 auto; min-height: 0; }
285.treebox { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
379.treebox { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
286.treebox h2 { margin: 0 0 0.5rem; font-size: 1.15rem; flex: none; }
380.treebox h2 { margin: 0 0 0.5rem; font-size: 1.15rem; flex: none; }
287.treebox > input { flex: none; }
381.treebox > input { flex: none; }
@@ -313,13 +407,20 @@ table.md th, table.md td { border: 1px solid var(--line); padding: 0.4rem 0.6rem
313.treelist li.depth-6, .treelist li.depth-7, .treelist li.depth-8 { padding-left: 4.4rem; }
407.treelist li.depth-6, .treelist li.depth-7, .treelist li.depth-8 { padding-left: 4.4rem; }
314.filecol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
408.filecol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
315.filecol > .toolbar { flex: none; margin-top: 0; }
409.filecol > .toolbar { flex: none; margin-top: 0; }
316.filepane { flex: 1 1 auto; min-height: 0; overflow: auto; }
410.filepane { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; }
411.filepane:has(.codebox) { display: flex; flex-direction: column; overflow: hidden; }
412.filepane:has(.codebox) > .filename,
413.filepane:has(.codebox) > .commitbar { flex: none; }
317.filename { display: flex; align-items: center; gap: 0.35rem; margin: 0.2rem 0 0.6rem; }
414.filename { display: flex; align-items: center; gap: 0.35rem; margin: 0.2rem 0 0.6rem; }
318.codebox { margin-top: 0.8rem; overflow: auto; }
415.codebox { margin-top: 0.8rem; overflow: auto; }
319.fileview .codebox { overflow: visible; }
416.fileview .codebox {
417 overflow: auto; flex: 1 1 auto; min-height: 0; min-width: 0; margin-top: 0;
418}
320table.code { border-collapse: collapse; width: 100%; }
419table.code { border-collapse: collapse; width: 100%; }
420.fileview table.code { width: max-content; min-width: 100%; }
321table.code td { border: 0; padding: 0 0.7rem; vertical-align: top; font-family: ui-monospace, monospace; font-size: 0.86rem; line-height: 1.45; }
421table.code td { border: 0; padding: 0 0.7rem; vertical-align: top; font-family: ui-monospace, monospace; font-size: 0.86rem; line-height: 1.45; }
322table.code td.ln { color: #8c959f; text-align: right; width: 1%; user-select: none; background: #f6f8fa; }
422table.code td.ln { color: #8c959f; text-align: right; width: 1%; user-select: none; background: #f6f8fa; }
423.fileview table.code td.ln { position: sticky; left: 0; z-index: 1; }
323table.code td.src { white-space: pre; }
424table.code td.src { white-space: pre; }
324.hl-k { color: #8250df; }
425.hl-k { color: #8250df; }
325.hl-s { color: #cf222e; }
426.hl-s { color: #cf222e; }
@@ -384,6 +485,14 @@ table.code td.src { white-space: pre; }
384}
485}
385.repolist { list-style: none; padding: 0; margin: .4rem 0 1rem; }
486.repolist { list-style: none; padding: 0; margin: .4rem 0 1rem; }
386.repolist > li { display: flex; align-items: center; gap: .7rem; padding: .75rem .2rem; border-bottom: 1px solid var(--line); }
487.repolist > li { display: flex; align-items: center; gap: .7rem; padding: .75rem .2rem; border-bottom: 1px solid var(--line); }
488.repolist .tile, .repolist .avatar { width: 32px; height: 32px; font-size: .9rem; }
489.repolist form { margin: 0; }
490.picklist { border: 1px solid var(--line); border-radius: 10px; margin: .35rem 0 .8rem; padding: .35rem; }
491.picklist legend { padding: 0 .25rem; color: var(--muted); font-size: var(--fs-sm); }
492.picklist label, label.pickrow { display: flex; align-items: center; gap: .55rem; padding: .35rem .45rem; border-radius: 8px; cursor: pointer; }
493.picklist label:has(input:checked) { background: #eef4ff; }
494.picklist input, label.pickrow input { margin: 0; }
495.picklist .tile, .picklist .avatar, label.pickrow .avatar { width: 24px; height: 24px; font-size: .75rem; }
387.reponame { font-weight: 600; text-decoration: none; }
496.reponame { font-weight: 600; text-decoration: none; }
388.stars { color: #9a6700; white-space: nowrap; }
497.stars { color: #9a6700; white-space: nowrap; }
389.grown { flex: 1; }
498.grown { flex: 1; }
@@ -393,6 +502,24 @@ table.code td.src { white-space: pre; }
393.rowmenu .menu-panel { position: absolute; right: 0; z-index: 3; min-width: 9rem; }
502.rowmenu .menu-panel { position: absolute; right: 0; z-index: 3; min-width: 9rem; }
394.rowmenu .menu-panel button, .rowmenu .menu-panel form { width: 100%; }
503.rowmenu .menu-panel button, .rowmenu .menu-panel form { width: 100%; }
395.rowmenu .menu-panel button { text-align: left; border-radius: 8px; }
504.rowmenu .menu-panel button { text-align: left; border-radius: 8px; }
505details.piperetry { display: inline-block; vertical-align: middle; flex: none; }
506.stagecell { display: flex; align-items: center; gap: .45rem; }
507.pipehead { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
508.menu-panel.piperetry { min-width: 14rem; padding: .3rem; }
509.menu-panel.piperetry[popover]:popover-open {
510 width: max-content;
511 min-width: 14rem;
512 max-width: min(18rem, calc(100vw - 16px));
513 padding: .3rem;
514}
515.menu-panel.piperetry form { margin: 0; }
516.menu-panel.piperetry form[hidden] { display: none !important; }
517.menu-panel.piperetry button {
518 display: block; width: 100%; text-align: left; background: transparent; border: 0;
519 border-radius: 8px; padding: .45rem .6rem; cursor: pointer; font: inherit; color: inherit;
520 white-space: nowrap;
521}
522.menu-panel.piperetry button:hover { background: #f3f6fb; }
396img.tile { object-fit: cover; background: #fff; }
523img.tile { object-fit: cover; background: #fff; }
397@font-face {
524@font-face {
398 font-family: "Noto Sans Cuneiform";
525 font-family: "Noto Sans Cuneiform";
@@ -674,6 +801,7 @@ button.section-toggle {
674.jobside h2 { font-size: 0.95rem; margin: 0.9rem 0 0.3rem; }
801.jobside h2 { font-size: 0.95rem; margin: 0.9rem 0 0.3rem; }
675.related { list-style: none; margin: 0; padding: 0; }
802.related { list-style: none; margin: 0; padding: 0; }
676.related li { display: flex; align-items: center; gap: 0.3rem; }
803.related li { display: flex; align-items: center; gap: 0.3rem; }
804.related li[hidden] { display: none !important; }
677.related .arrow { width: 1rem; color: var(--muted); }
805.related .arrow { width: 1rem; color: var(--muted); }
678.editorhead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.7rem; }
806.editorhead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.7rem; }
679.editorhead h2 { margin: 0; font-size: 1.15rem; }
807.editorhead h2 { margin: 0; font-size: 1.15rem; }
@@ -848,6 +976,76 @@ a.btn { text-decoration: none; }
848 text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
976 text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
849}
977}
850.when-short { white-space: nowrap; }
978.when-short { white-space: nowrap; }
979.refhead {
980 display: flex; align-items: center; justify-content: space-between;
981 gap: var(--sp-3); flex-wrap: wrap; margin: 0 0 var(--sp-3);
982}
983.refhead h1 { margin: 0; }
984.refhead > button { margin-left: auto; }
985.reftabs { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: flex-end; min-width: 0; border-bottom: 1px solid var(--line); }
986.reftabs a {
987 text-decoration: none; color: var(--muted); font-weight: 500;
988 padding: 0.45rem 0; margin-bottom: -1px; border-bottom: 2px solid transparent;
989}
990.reftabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
991.refsearch {
992 display: flex; align-items: center; gap: 0.4rem; margin: 0 0 var(--sp-3);
993 border: 1px solid var(--line); border-radius: var(--radius); background: white;
994 min-height: var(--control-h); padding: 0 0.55rem;
995}
996.refsearch input { border: 0; min-height: 0; padding: 0; background: transparent; flex: 1; width: auto; }
997.refsearch input:focus { outline: none; }
998.refsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
999.refsearch button.refgo {
1000 background: transparent; color: var(--muted); border: 0; min-height: 0; width: 28px; padding: 0;
1001}
1002.refgroup {
1003 background: #f4f1f8; border: 1px solid #e4dfeb; border-radius: var(--radius-lg);
1004 padding: 0.35rem 0.85rem 0.7rem; margin: 0 0 var(--sp-4);
1005}
1006.refgroup h2 { margin: 0.55rem 0.2rem; font-size: 0.95rem; }
1007.refrow {
1008 display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
1009 background: white; border: 1px solid var(--line); border-radius: var(--radius-lg);
1010 padding: 0.7rem 0.85rem; margin: 0.45rem 0;
1011}
1012.refrow[hidden], .refgroup[hidden] { display: none !important; }
1013.refmain { min-width: 0; }
1014.refname { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
1015.refname a { color: var(--ink); text-decoration: none; font-weight: 650; }
1016.refname code, .refname a code { font-family: var(--mono); font-size: 0.95rem; }
1017.refcopy { min-height: 24px; width: 24px; padding: 0; }
1018.refbadge { text-transform: lowercase; background: #eef1f4; color: #57606a; border-color: transparent; }
1019.refbadge.def { background: var(--blue-soft); color: var(--blue-deep); }
1020.refmeta {
1021 margin: 0.28rem 0 0; color: var(--muted); font-size: var(--fs-sm);
1022 display: flex; flex-wrap: wrap; gap: 0.35rem 0.55rem; align-items: center;
1023}
1024.refmeta a { color: inherit; }
1025.refdot { color: var(--muted); }
1026.refsubject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36rem; }
1027.refnote { margin: 0.35rem 0 0; white-space: pre-wrap; }
1028.refacts { display: flex; align-items: center; gap: 0.35rem; flex: none; }
1029.refacts .tiny {
1030 min-height: 1.7rem; padding: 0 0.45rem; font-size: var(--fs-sm);
1031 background: white; color: var(--ink); border: 1px solid var(--line);
1032 border-radius: var(--radius); text-decoration: none; line-height: 1.2;
1033}
1034.refacts .rowmenu > summary { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; min-height: 2rem; }
1035.refdlbtn::after {
1036 content: ""; width: 0.32rem; height: 0.32rem; margin-left: 0.2rem;
1037 border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
1038 transform: translateY(-1px) rotate(45deg);
1039}
1040.menu-panel.refdl a { display: block; padding: 0.4rem 0.15rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
1041.menu-panel.refdl[popover]:popover-open { width: max-content; min-width: 8.5rem; max-width: 14rem; padding: 0.35rem 0.9rem; }
1042.rowmenu .menu-panel a { display: block; padding: 0.35rem 0.2rem; text-decoration: none; color: var(--ink); }
1043.refempty { margin: 0.4rem 0.2rem 0.6rem; }
1044@media (max-width: 800px) {
1045 .refrow { flex-direction: column; }
1046 .refacts { flex-wrap: wrap; }
1047 .refsubject { max-width: 100%; }
1048}
851.mergewhy {
1049.mergewhy {
852 border: 1px solid var(--line); border-radius: var(--radius);
1050 border: 1px solid var(--line); border-radius: var(--radius);
853 padding: 0.7rem 0.9rem; margin: 0.6rem 0; background: #fff8f0;
1051 padding: 0.7rem 0.9rem; margin: 0.6rem 0; background: #fff8f0;
@@ -945,10 +1143,15 @@ form.wh .grid-2 label { margin-top: 0; }
945@media (max-width: 800px) {
1143@media (max-width: 800px) {
946 .proj, .fileview, .joblayout { grid-template-columns: minmax(0, 1fr); }
1144 .proj, .fileview, .joblayout { grid-template-columns: minmax(0, 1fr); }
947 .proj > *, .fileview > *, .toolbar, .commitbar, .hscroll { min-width: 0; max-width: 100%; }
1145 .proj > *, .fileview > *, .toolbar, .commitbar, .hscroll { min-width: 0; max-width: 100%; }
1146 body:has(main.fill) { height: auto; overflow: auto; }
1147 .frame.with-side:has(main.fill),
1148 .content:has(main.fill) { height: auto; overflow: visible; }
1149 main.fill { display: block; height: auto; overflow: visible; }
948 .fileview { height: auto; min-height: 0; }
1150 .fileview { height: auto; min-height: 0; }
949 .fileview .treelist { max-height: 40vh; flex: none; }
1151 .fileview .treelist { max-height: none; overflow: visible; flex: none; }
950 .fileview .filepane { overflow: visible; }
1152 .fileview .filepane,
951 .fileview .codebox { overflow: auto; }
1153 .filepane:has(.codebox) { overflow: visible; display: block; }
1154 .fileview .codebox { overflow: auto; flex: none; max-height: none; }
952 .heat-foot { flex-direction: column; align-items: flex-start; }
1155 .heat-foot { flex-direction: column; align-items: flex-start; }
953 .heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }
1156 .heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }
954 .repolist > li { flex-wrap: wrap; }
1157 .repolist > li { flex-wrap: wrap; }
@@ -956,12 +1159,142 @@ form.wh .grid-2 label { margin-top: 0; }
956 .usercard-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
1159 .usercard-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
957 .pagehead { align-items: flex-start; }
1160 .pagehead { align-items: flex-start; }
958 .pageacts { flex-wrap: wrap; justify-content: flex-end; }
1161 .pageacts { flex-wrap: wrap; justify-content: flex-end; }
1162 .mrwidget .rowline { align-items: flex-start; }
1163 .sub { flex-wrap: nowrap; overflow-x: auto; }
959}
1164}
960.issuelist { list-style: none; margin: 0; padding: 0; }
1165.issuelist { list-style: none; margin: 0; padding: 0; }
961.issuelist > li { border-bottom: 1px solid var(--line); padding: 0.6rem 0; min-height: 2.4rem; }
1166.issuelist > li { border-bottom: 1px solid var(--line); padding: 0.6rem 0; min-height: 2.4rem; }
1167.flowhead {
1168 display: flex; align-items: center; justify-content: space-between;
1169 gap: var(--sp-3); flex-wrap: wrap; margin: 0 0 var(--sp-3);
1170}
1171.flowtabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; min-width: 0; }
1172.flowtabs a {
1173 display: inline-flex; align-items: center; gap: 0.35rem;
1174 text-decoration: none; color: var(--ink); font-weight: 500;
1175 padding: 0.35rem 0.65rem; border: 1px solid transparent; border-radius: var(--radius);
1176}
1177.flowtabs a.on { background: #f4f7fb; border-color: var(--line); }
1178.flowcount {
1179 display: inline-block; min-width: 1.15rem; padding: 0 0.35rem; text-align: center;
1180 background: #eef2f6; color: var(--muted); border-radius: 999px; font-size: 0.78rem; font-weight: 650;
1181}
1182.flowtabs a.on .flowcount { background: var(--blue-soft); color: var(--blue-deep); }
1183.flowbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin: 0 0 var(--sp-2); }
1184.flowsearch {
1185 position: relative;
1186 flex: 1 1 16rem; display: flex; align-items: center; gap: 0.4rem; min-width: 0;
1187 border: 1px solid var(--line); border-radius: var(--radius); background: white;
1188 min-height: var(--control-h); padding: 0 0.35rem 0 0.55rem; color: var(--muted);
1189}
1190.flowsearch input { border: 0; min-height: 0; padding: 0; background: transparent; flex: 1; width: auto; color: var(--ink); }
1191.flowsearch input:focus { outline: none; }
1192.flowsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
1193.flowsearch button.flowgo {
1194 position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
1195 clip: rect(0, 0, 0, 0); border: 0; background: transparent; color: transparent;
1196}
1197.flowbar > select { width: auto; flex: 0 1 12rem; }
1198a.flowdir { width: var(--control-h); min-width: var(--control-h); padding: 0; }
1199.flowlist { list-style: none; margin: 0; padding: 0; }
1200.flowrow {
1201 display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4);
1202 padding: 0.85rem 0.15rem; border-bottom: 1px solid var(--line);
1203}
1204.flowrow:first-child { border-top: 1px solid var(--line); }
1205.flowmain { min-width: 0; }
1206.flowtitle { color: inherit; text-decoration: none; font-size: 1rem; line-height: 1.35; }
1207.flowtitle strong { font-weight: 650; }
1208.flowtitle:hover strong { text-decoration: underline; }
1209.flowdraft { color: var(--muted); font-weight: 500; }
1210.flowmeta {
1211 margin: 0.28rem 0 0; color: var(--muted); font-size: var(--fs-sm);
1212 display: flex; flex-wrap: wrap; gap: 0.35rem 0.45rem; align-items: center;
1213}
1214.flowmeta a { color: inherit; }
1215.flowdot { color: var(--line); }
1216.flowtarget {
1217 border: 1px solid var(--line); border-radius: 999px; padding: 0 0.4rem;
1218 background: white; color: var(--ink);
1219}
1220.flowcomments { display: inline-flex; align-items: center; gap: 0.2rem; }
1221a.flowpipe { padding: 0; background: transparent; min-height: 0; line-height: 0; }
1222a.flowpipe .mark { width: 14px; height: 14px; }
1223a.flowpipe.passed .mark::after { left: 4px; top: 2px; width: 3px; height: 6px; }
1224.flowside { display: flex; flex-direction: column; align-items: flex-end; gap: 0.28rem; flex: none; text-align: right; }
1225.flowbadge {
1226 display: inline-block; border-radius: 999px; padding: 0.08rem 0.55rem;
1227 font-size: 0.78rem; font-weight: 650; background: #e5f6ec; color: #146c43;
1228}
1229.flowbadge.merged { background: var(--blue-soft); color: var(--blue-deep); }
1230.flowbadge.closed { background: #fde8e8; color: var(--bad); }
1231.flowupdated { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
1232.flowempty { padding: 0.8rem 0; }
1233@media (max-width: 800px) {
1234 .flowrow { flex-direction: column; gap: 0.4rem; }
1235 .flowside { flex-direction: row; align-items: center; }
1236 .flowbar > select { flex: 1 1 8rem; }
1237}
962.lab { display: inline-block; color: #fff; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.78rem; margin: 0 0.2rem; }
1238.lab { display: inline-block; color: #fff; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.78rem; margin: 0 0.2rem; }
963.issue-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }
1239.issue-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }
964.checks label { display: block; margin: 0.2rem 0; }
1240.checks label { display: block; margin: 0.2rem 0; }
1241.mrhead { margin: 0 0 var(--sp-4); }
1242.mrhead h1 { margin: 0.35rem 0 0.15rem; overflow-wrap: anywhere; }
1243.mrbadges { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0; }
1244.mrstate {
1245 display: inline-flex; align-items: center; border-radius: 999px;
1246 padding: 0.18rem 0.7rem; font-weight: 650; font-size: 0.84rem;
1247}
1248.mrstate.open { background: #e5f6ec; color: #146c43; }
1249.mrstate.merged { background: var(--blue-soft); color: var(--blue-deep); }
1250.mrstate.closed { background: #fde8e8; color: var(--bad); }
1251.mrmeta { color: var(--muted); margin: 0.15rem 0 0.45rem; }
1252.mrwant { margin: 0.2rem 0; line-height: 1.9; }
1253.mrwant span:empty { display: none; }
1254.mrwant a.who {
1255 display: inline-flex; align-items: center; gap: 0.35rem; vertical-align: middle;
1256 margin-right: 0.15rem; font-weight: 650; color: var(--ink); text-decoration: none;
1257}
1258.mrwant a.who:hover { text-decoration: underline; }
1259.branchchip {
1260 display: inline-flex; align-items: center; gap: 0.1rem; max-width: 100%;
1261 background: #f6f8fa; border: 1px solid var(--line); border-radius: 6px;
1262 padding: 0 0.1rem 0 0.4rem; vertical-align: middle;
1263}
1264.branchchip code { font-size: 0.85rem; overflow-wrap: anywhere; }
1265.branchchip button.copy {
1266 border: 0; background: transparent; color: var(--muted); cursor: pointer;
1267 font: inherit; font-size: 0.78rem; min-height: 1.6rem; padding: 0 0.4rem;
1268}
1269.mrchips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.35rem 0 0; }
1270.mrwidget {
1271 background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
1272 margin: var(--sp-3) 0 var(--sp-4);
1273}
1274.mrwidget .rowline {
1275 display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem;
1276 padding: 0.75rem 1rem; border-bottom: 1px solid var(--line);
1277}
1278.mrwidget .rowline:last-child { border-bottom: 0; }
1279.mrwidget h2 { margin: 0; font-size: 0.95rem; flex: none; }
1280.mrwidget .mrpipe { margin: 0; min-width: 0; }
1281.mrwidget .checks { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; align-items: center; }
1282.mrwidget .checks label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; }
1283.mrwidget .checks label:last-child { flex: 1 1 100%; display: block; }
1284.mrwidget textarea { min-height: 4.5rem; }
1285.mrwidget form { margin: 0; }
1286.revblock { flex: 1 1 16rem; min-width: 0; }
1287.mrreviews { list-style: none; padding: 0; margin: 0 0 0.35rem; }
1288.mrreviews li { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; padding: 0.15rem 0; }
1289.mrreviews form { margin: 0; }
1290.mergeacts { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
1291.mergedby { margin: 0; }
1292.mergedby .branchchip { margin-left: 0.45rem; vertical-align: middle; }
1293.sub .count {
1294 display: inline-block; margin-left: 0.3rem; background: #eef2f7; color: var(--muted);
1295 border-radius: 999px; padding: 0 0.4rem; font-size: 0.75rem; font-weight: 650;
1296}
1297.sub a.on .count { background: #fff; color: var(--blue-deep); }
965.taskcount { margin: 0.7rem 0 0.2rem; font-size: 0.9rem; }
1298.taskcount { margin: 0.7rem 0 0.2rem; font-size: 0.9rem; }
966ul.tasks { list-style: none; padding-left: 0.1rem; }
1299ul.tasks { list-style: none; padding-left: 0.1rem; }
967ul.tasks > li { display: flex; align-items: flex-start; gap: 0.35rem; margin: 0.25rem 0; }
1300ul.tasks > li { display: flex; align-items: flex-start; gap: 0.35rem; margin: 0.25rem 0; }
internal/server/static/tags.js +10 −0
@@ -24,4 +24,14 @@
24 24 dialog.close();
25 25 });
26 26 }
27 var form = document.querySelector("[data-tag-form]");
28 document.querySelectorAll("[data-tag-create]").forEach(function (btn) {
29 btn.addEventListener("click", function () {
30 if (form && form.showModal) form.showModal();
31 });
32 });
33 if (form) {
34 var shut = form.querySelector("[data-tag-form-close]");
35 if (shut) shut.addEventListener("click", function () { form.close(); });
36 }
27 37 })();
@@ -24,4 +24,14 @@
24 dialog.close();
24 dialog.close();
25 });
25 });
26 }
26 }
27 var form = document.querySelector("[data-tag-form]");
28 document.querySelectorAll("[data-tag-create]").forEach(function (btn) {
29 btn.addEventListener("click", function () {
30 if (form && form.showModal) form.showModal();
31 });
32 });
33 if (form) {
34 var shut = form.querySelector("[data-tag-form-close]");
35 if (shut) shut.addEventListener("click", function () { form.close(); });
36 }
27})();
37})();
internal/server/tags.go +60 −7
@@ -9,6 +9,7 @@ import (
9 9 "gitlab.com/Timfa/bluegit/internal/access"
10 10 "gitlab.com/Timfa/bluegit/internal/gitrepo"
11 11 "gitlab.com/Timfa/bluegit/internal/i18n"
12 "gitlab.com/Timfa/bluegit/internal/store"
12 13 )
13 14
14 15 func (s *Server) tags(w http.ResponseWriter, r *http.Request) {
@@ -41,13 +42,15 @@ func (s *Server) tags(w http.ResponseWriter, r *http.Request) {
41 42 if len(short) > 10 {
42 43 short = short[:10]
43 44 }
44 when := ""
45 when, date := "", ""
45 46 if info.Unix > 0 {
46 when = i18n.FormatDate(lang, time.Unix(info.Unix, 0).UTC())
47 at := time.Unix(info.Unix, 0).UTC()
48 when = i18n.Ago(lang, info.Unix)
49 date = i18n.FormatDate(lang, at)
47 50 }
48 51 row := TagRow{
49 52 Name: info.Name, Message: info.Message, SHA: info.CommitSHA, Short: short,
50 Subject: info.CommitSubject, Date: when, Annotated: info.Annotated,
53 Subject: info.CommitSubject, Date: date, When: when, Annotated: info.Annotated,
51 54 Protected: protected, HasRelease: released[info.Name],
52 55 CanDelete: role.CanWriteCode() && (!protected || role.CanManageSettings()),
53 56 ZipURL: tagArchiveURL(repo, info.Name, "zip"),
@@ -82,6 +85,52 @@ func (s *Server) deleteTag(w http.ResponseWriter, r *http.Request) {
82 85 s.redirect(w, r, back, s.tr(r, "flash.tagDeleted"), "")
83 86 }
84 87
88 // commitArchive levert git archive van één volledige commit-sha.
89 // Het pad is de URL die makepkg ophaalt:
90 // /{owner}/{repo}/-/archive/{sha}/{name}-{sha}.tar.gz
91 func (s *Server) commitArchive(w http.ResponseWriter, r *http.Request) {
92 _, repo, _, ok := s.guard(w, r, access.RoleReadonly)
93 if !ok {
94 return
95 }
96 rev := r.PathValue("rev")
97 format := archiveFormat(r.PathValue("file"))
98 if format == "" || !fullHexSHA(rev) {
99 http.NotFound(w, r)
100 return
101 }
102 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
103 sha := gitOne(r.Context(), s.Git, dir, "rev-parse", "--verify", "--quiet", rev+"^{commit}")
104 if sha != rev {
105 http.NotFound(w, r)
106 return
107 }
108 s.writeArchive(w, r, repo, dir, sha, sha, format)
109 }
110
111 func archiveFormat(file string) string {
112 switch {
113 case strings.HasSuffix(file, ".tar.gz"):
114 return "tar.gz"
115 case strings.HasSuffix(file, ".zip"):
116 return "zip"
117 default:
118 return ""
119 }
120 }
121
122 func fullHexSHA(rev string) bool {
123 if len(rev) != 40 {
124 return false
125 }
126 for _, c := range rev {
127 if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
128 return false
129 }
130 }
131 return true
132 }
133
85 134 func (s *Server) tagArchive(w http.ResponseWriter, r *http.Request) {
86 135 _, repo, _, ok := s.guard(w, r, access.RoleReadonly)
87 136 if !ok {
@@ -98,16 +147,20 @@ func (s *Server) tagArchive(w http.ResponseWriter, r *http.Request) {
98 147 http.NotFound(w, r)
99 148 return
100 149 }
101 filename := archiveFilename(repo.Name, name, format)
150 s.writeArchive(w, r, repo, dir, name, name, format)
151 }
152
153 func (s *Server) writeArchive(w http.ResponseWriter, r *http.Request, repo store.Repo, dir, rev, label, format string) {
154 filename := archiveFilename(repo.Name, label, format)
102 155 if format == "zip" {
103 156 w.Header().Set("Content-Type", "application/zip")
104 157 } else {
105 158 w.Header().Set("Content-Type", "application/gzip")
106 159 }
107 160 w.Header().Set("Content-Disposition", "attachment; filename=\""+filename+"\"")
108 prefix := repo.Name + "-" + strings.ReplaceAll(name, "/", "-")
109 if err := gitrepo.Archive(r.Context(), w, s.Git, dir, prefix, name, format); err != nil && s.Log != nil {
110 s.Log.Error("tag archief", "err", err, "tag", name)
161 prefix := repo.Name + "-" + strings.ReplaceAll(label, "/", "-")
162 if err := gitrepo.ArchiveAt(r.Context(), w, s.Git, dir, prefix, rev, format); err != nil && s.Log != nil {
163 s.Log.Error("archief", "err", err, "rev", rev)
111 164 }
112 165 }
113 166
@@ -9,6 +9,7 @@ import (
9 "gitlab.com/Timfa/bluegit/internal/access"
9 "gitlab.com/Timfa/bluegit/internal/access"
10 "gitlab.com/Timfa/bluegit/internal/gitrepo"
10 "gitlab.com/Timfa/bluegit/internal/gitrepo"
11 "gitlab.com/Timfa/bluegit/internal/i18n"
11 "gitlab.com/Timfa/bluegit/internal/i18n"
12 "gitlab.com/Timfa/bluegit/internal/store"
12)
13)
13
14
14func (s *Server) tags(w http.ResponseWriter, r *http.Request) {
15func (s *Server) tags(w http.ResponseWriter, r *http.Request) {
@@ -41,13 +42,15 @@ func (s *Server) tags(w http.ResponseWriter, r *http.Request) {
41 if len(short) > 10 {
42 if len(short) > 10 {
42 short = short[:10]
43 short = short[:10]
43 }
44 }
44 when := ""
45 when, date := "", ""
45 if info.Unix > 0 {
46 if info.Unix > 0 {
46 when = i18n.FormatDate(lang, time.Unix(info.Unix, 0).UTC())
47 at := time.Unix(info.Unix, 0).UTC()
48 when = i18n.Ago(lang, info.Unix)
49 date = i18n.FormatDate(lang, at)
47 }
50 }
48 row := TagRow{
51 row := TagRow{
49 Name: info.Name, Message: info.Message, SHA: info.CommitSHA, Short: short,
52 Name: info.Name, Message: info.Message, SHA: info.CommitSHA, Short: short,
50 Subject: info.CommitSubject, Date: when, Annotated: info.Annotated,
53 Subject: info.CommitSubject, Date: date, When: when, Annotated: info.Annotated,
51 Protected: protected, HasRelease: released[info.Name],
54 Protected: protected, HasRelease: released[info.Name],
52 CanDelete: role.CanWriteCode() && (!protected || role.CanManageSettings()),
55 CanDelete: role.CanWriteCode() && (!protected || role.CanManageSettings()),
53 ZipURL: tagArchiveURL(repo, info.Name, "zip"),
56 ZipURL: tagArchiveURL(repo, info.Name, "zip"),
@@ -82,6 +85,52 @@ func (s *Server) deleteTag(w http.ResponseWriter, r *http.Request) {
82 s.redirect(w, r, back, s.tr(r, "flash.tagDeleted"), "")
85 s.redirect(w, r, back, s.tr(r, "flash.tagDeleted"), "")
83}
86}
84
87
88// commitArchive levert git archive van één volledige commit-sha.
89// Het pad is de URL die makepkg ophaalt:
90// /{owner}/{repo}/-/archive/{sha}/{name}-{sha}.tar.gz
91func (s *Server) commitArchive(w http.ResponseWriter, r *http.Request) {
92 _, repo, _, ok := s.guard(w, r, access.RoleReadonly)
93 if !ok {
94 return
95 }
96 rev := r.PathValue("rev")
97 format := archiveFormat(r.PathValue("file"))
98 if format == "" || !fullHexSHA(rev) {
99 http.NotFound(w, r)
100 return
101 }
102 dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
103 sha := gitOne(r.Context(), s.Git, dir, "rev-parse", "--verify", "--quiet", rev+"^{commit}")
104 if sha != rev {
105 http.NotFound(w, r)
106 return
107 }
108 s.writeArchive(w, r, repo, dir, sha, sha, format)
109}
110
111func archiveFormat(file string) string {
112 switch {
113 case strings.HasSuffix(file, ".tar.gz"):
114 return "tar.gz"
115 case strings.HasSuffix(file, ".zip"):
116 return "zip"
117 default:
118 return ""
119 }
120}
121
122func fullHexSHA(rev string) bool {
123 if len(rev) != 40 {
124 return false
125 }
126 for _, c := range rev {
127 if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
128 return false
129 }
130 }
131 return true
132}
133
85func (s *Server) tagArchive(w http.ResponseWriter, r *http.Request) {
134func (s *Server) tagArchive(w http.ResponseWriter, r *http.Request) {
86 _, repo, _, ok := s.guard(w, r, access.RoleReadonly)
135 _, repo, _, ok := s.guard(w, r, access.RoleReadonly)
87 if !ok {
136 if !ok {
@@ -98,16 +147,20 @@ func (s *Server) tagArchive(w http.ResponseWriter, r *http.Request) {
98 http.NotFound(w, r)
147 http.NotFound(w, r)
99 return
148 return
100 }
149 }
101 filename := archiveFilename(repo.Name, name, format)
150 s.writeArchive(w, r, repo, dir, name, name, format)
151}
152
153func (s *Server) writeArchive(w http.ResponseWriter, r *http.Request, repo store.Repo, dir, rev, label, format string) {
154 filename := archiveFilename(repo.Name, label, format)
102 if format == "zip" {
155 if format == "zip" {
103 w.Header().Set("Content-Type", "application/zip")
156 w.Header().Set("Content-Type", "application/zip")
104 } else {
157 } else {
105 w.Header().Set("Content-Type", "application/gzip")
158 w.Header().Set("Content-Type", "application/gzip")
106 }
159 }
107 w.Header().Set("Content-Disposition", "attachment; filename=\""+filename+"\"")
160 w.Header().Set("Content-Disposition", "attachment; filename=\""+filename+"\"")
108 prefix := repo.Name + "-" + strings.ReplaceAll(name, "/", "-")
161 prefix := repo.Name + "-" + strings.ReplaceAll(label, "/", "-")
109 if err := gitrepo.Archive(r.Context(), w, s.Git, dir, prefix, name, format); err != nil && s.Log != nil {
162 if err := gitrepo.ArchiveAt(r.Context(), w, s.Git, dir, prefix, rev, format); err != nil && s.Log != nil {
110 s.Log.Error("tag archief", "err", err, "tag", name)
163 s.Log.Error("archief", "err", err, "rev", rev)
111 }
164 }
112}
165}
113
166
internal/server/tags_test.go +3 −3
@@ -97,7 +97,7 @@ func TestTagsPage(t *testing.T) {
97 97 }
98 98 page := read(t, res)
99 99 for _, want := range []string{
100 `class="on">Tags`, `Find a tag`, `Create tag`, `No tags yet.`, `value="master"`, `/assets/tags.js`, `data-tag-dialog`,
100 `class="on">Tags`, `Find a tag`, `New tag`, `No tags yet.`, `value="master"`, `/assets/tags.js`, `data-tag-dialog`,
101 101 } {
102 102 if !strings.Contains(page, want) {
103 103 t.Fatalf("tags mist %q\n%s", want, page)
@@ -318,7 +318,7 @@ func TestTagsPage(t *testing.T) {
318 318 t.Fatal(err)
319 319 }
320 320 roPage := read(t, res)
321 if strings.Contains(roPage, "Create tag") || strings.Contains(roPage, "data-tag-dialog") || strings.Contains(roPage, "data-tag-open") {
321 if strings.Contains(roPage, "New tag") || strings.Contains(roPage, "data-tag-dialog") || strings.Contains(roPage, "data-tag-open") {
322 322 t.Fatalf("alleen-lezen ziet het formulier:\n%s", roPage)
323 323 }
324 324 res, err = roClient.PostForm(ts.URL+"/tim/tags/-/tags", url.Values{"csrf": {csrfOf(t, roPage)}, "name": {"x"}, "target": {"master"}})
@@ -354,7 +354,7 @@ func TestTagsPage(t *testing.T) {
354 354 t.Fatal(err)
355 355 }
356 356 nl := read(t, res)
357 for _, want := range []string{"Tag aanmaken", "Zoek een tag", "Zonder bericht", "Verwijderen"} {
357 for _, want := range []string{"Nieuwe tag", "Zoek een tag", "Zonder bericht", "Verwijderen"} {
358 358 if !strings.Contains(nl, want) {
359 359 t.Fatalf("nederlands mist %q\n%s", want, nl)
360 360 }
@@ -97,7 +97,7 @@ func TestTagsPage(t *testing.T) {
97 }
97 }
98 page := read(t, res)
98 page := read(t, res)
99 for _, want := range []string{
99 for _, want := range []string{
100 `class="on">Tags`, `Find a tag`, `Create tag`, `No tags yet.`, `value="master"`, `/assets/tags.js`, `data-tag-dialog`,
100 `class="on">Tags`, `Find a tag`, `New tag`, `No tags yet.`, `value="master"`, `/assets/tags.js`, `data-tag-dialog`,
101 } {
101 } {
102 if !strings.Contains(page, want) {
102 if !strings.Contains(page, want) {
103 t.Fatalf("tags mist %q\n%s", want, page)
103 t.Fatalf("tags mist %q\n%s", want, page)
@@ -318,7 +318,7 @@ func TestTagsPage(t *testing.T) {
318 t.Fatal(err)
318 t.Fatal(err)
319 }
319 }
320 roPage := read(t, res)
320 roPage := read(t, res)
321 if strings.Contains(roPage, "Create tag") || strings.Contains(roPage, "data-tag-dialog") || strings.Contains(roPage, "data-tag-open") {
321 if strings.Contains(roPage, "New tag") || strings.Contains(roPage, "data-tag-dialog") || strings.Contains(roPage, "data-tag-open") {
322 t.Fatalf("alleen-lezen ziet het formulier:\n%s", roPage)
322 t.Fatalf("alleen-lezen ziet het formulier:\n%s", roPage)
323 }
323 }
324 res, err = roClient.PostForm(ts.URL+"/tim/tags/-/tags", url.Values{"csrf": {csrfOf(t, roPage)}, "name": {"x"}, "target": {"master"}})
324 res, err = roClient.PostForm(ts.URL+"/tim/tags/-/tags", url.Values{"csrf": {csrfOf(t, roPage)}, "name": {"x"}, "target": {"master"}})
@@ -354,7 +354,7 @@ func TestTagsPage(t *testing.T) {
354 t.Fatal(err)
354 t.Fatal(err)
355 }
355 }
356 nl := read(t, res)
356 nl := read(t, res)
357 for _, want := range []string{"Tag aanmaken", "Zoek een tag", "Zonder bericht", "Verwijderen"} {
357 for _, want := range []string{"Nieuwe tag", "Zoek een tag", "Zonder bericht", "Verwijderen"} {
358 if !strings.Contains(nl, want) {
358 if !strings.Contains(nl, want) {
359 t.Fatalf("nederlands mist %q\n%s", want, nl)
359 t.Fatalf("nederlands mist %q\n%s", want, nl)
360 }
360 }
internal/server/templates/branches.html +74 −65
@@ -1,71 +1,34 @@
1 1 {{define "branches"}}
2 2 {{template "layout-start" .}}
3 <header class="pagehead">
4 <h1>{{t "title.branches"}}</h1>
3 <div class="refhead">
4 <nav class="reftabs" aria-label="{{t "branch.actions"}}">
5 <a href="/{{.Repo.FullPath}}/-/branches?state=overview"{{if eq .Branch.State "overview"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.overview"}}</a>
6 <a href="/{{.Repo.FullPath}}/-/branches?state=active"{{if eq .Branch.State "active"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.active"}}</a>
7 <a href="/{{.Repo.FullPath}}/-/branches?state=stale"{{if eq .Branch.State "stale"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.stale"}}</a>
8 <a href="/{{.Repo.FullPath}}/-/branches?state=all"{{if eq .Branch.State "all"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.all"}}</a>
9 </nav>
5 10 {{if .CanWrite}}<button type="button" data-branch-open="create">{{t "branch.create"}}</button>{{end}}
6 </header>
7 <label class="branchsearch">{{t "branch.search"}}
8 <input type="search" data-branch-filter autocomplete="off" placeholder="{{t "branch.search"}}">
9 </label>
10 <div class="hscroll">
11 <table class="branchtable">
12 <thead>
13 <tr>
14 <th>{{t "branch.name"}}</th>
15 <th>{{t "branch.last"}}</th>
16 <th>{{t "branch.compare"}}</th>
17 <th>{{t "mr.pipeline"}}</th>
18 <th>{{t "mr.title"}}</th>
19 <th>{{t "branch.actions"}}</th>
20 </tr>
21 </thead>
22 <tbody>
23 {{range .Branches}}
24 <tr data-branch-row data-name="{{.Name}}">
25 <td>
26 <a href="/{{$.Repo.FullPath}}?rev={{urlquery .Name}}">{{.Name}}</a>
27 {{if .Default}}<span class="pill">{{t "branch.default"}}</span>{{end}}
28 {{if .Protected}}<span class="pill">{{t "vis.protected"}}</span>{{end}}
29 </td>
30 <td>
31 {{if .SHA}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a> <span class="subject" title="{{.Subject}}">{{.Subject}}</span> <span class="muted when-short" title="{{.WhenTitle}}">{{.When}}</span>{{end}}
32 </td>
33 <td class="nums">
34 {{if and (eq .Ahead 0) (eq .Behind 0)}}<span class="muted">{{t "branch.even"}}</span>{{else}}
35 {{if .Ahead}}<span class="addstat">{{t "branch.ahead" .Ahead}}</span>{{end}}
36 {{if .Behind}}<span class="delstat">{{t "branch.behind" .Behind}}</span>{{end}}
37 {{end}}
38 </td>
39 <td>
40 {{if .PipeStatus}}<a class="status {{.PipeStatus}}" href="/{{$.Repo.FullPath}}/-/pipelines/{{.PipeID}}"><span class="mark"></span>{{.PipeLabel}}</a>{{end}}
41 </td>
42 <td class="mrlinks">
43 {{range .OpenMRs}}<a href="/{{$.Repo.FullPath}}/-/merge-requests/{{.}}">!{{.}}</a>{{end}}
44 </td>
45 <td class="branchacts">
46 <div class="branchline">
47 {{if not .Default}}
48 <a class="tiny" href="/{{$.Repo.FullPath}}/-/compare?from={{urlquery $.Repo.DefaultBranch}}&amp;to={{urlquery .Name}}">{{t "branch.compare"}}</a>
49 {{if not .OpenMRs}}<a class="tiny" href="/{{$.Repo.FullPath}}/-/merge-requests/new?source={{urlquery .Name}}&amp;target={{urlquery $.Repo.DefaultBranch}}">{{t "branch.mrShort"}}</a>{{end}}
50 {{end}}
51 {{if and $.CanWrite (not .Default) (not .Protected)}}
52 <details class="rowmenu tiny-menu">
53 <summary aria-label="{{t "branch.more"}}">⋯</summary>
54 <div class="menu-panel">
55 <button type="button" class="ghost" data-rename="{{.Name}}">{{t "branch.rename"}}</button>
56 <button type="button" class="ghost" data-delete="{{.Name}}">{{t "branch.delete"}}</button>
57 </div>
58 </details>
59 {{end}}
60 </div>
61 </td>
62 </tr>
63 {{else}}
64 <tr><td colspan="6" class="muted">{{t "repo.noBranches"}}</td></tr>
65 {{end}}
66 </tbody>
67 </table>
68 11 </div>
12 <label class="refsearch">
13 <input type="search" data-branch-filter autocomplete="off" placeholder="{{t "branch.filter"}}" aria-label="{{t "branch.filter"}}">
14 <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>
15 </label>
16 {{if and (not .Branch.Active) (not .Branch.Stale)}}
17 <p class="muted">{{t "repo.noBranches"}}</p>
18 {{else}}
19 {{if .Branch.ShowActive}}
20 <section class="refgroup" data-ref-group>
21 <h2>{{t "branch.group.active"}}</h2>
22 {{range .Branch.Active}}{{template "branchrow" .}}{{else}}<p class="muted refempty">{{t "branch.none.active"}}</p>{{end}}
23 </section>
24 {{end}}
25 {{if .Branch.ShowStale}}
26 <section class="refgroup" data-ref-group>
27 <h2>{{t "branch.group.stale"}}</h2>
28 {{range .Branch.Stale}}{{template "branchrow" .}}{{else}}<p class="muted refempty">{{t "branch.none.stale"}}</p>{{end}}
29 </section>
30 {{end}}
31 {{end}}
69 32 {{if .CanWrite}}
70 33 <dialog class="branch-dialog" data-branch-dialog="create">
71 34 <form method="post" action="/{{.Repo.FullPath}}/-/branches">
@@ -112,7 +75,53 @@
112 75 </div>
113 76 </form>
114 77 </dialog>
115 <script src="/assets/branch.js"></script>
116 78 {{end}}
79 <script src="/assets/branch.js"></script>
117 80 {{template "layout-end" .}}
118 81 {{end}}
82
83 {{define "branchrow"}}
84 <article class="refrow" data-branch-row data-name="{{.Name}}">
85 <div class="refmain">
86 <div class="refname">
87 <a href="/{{.RepoPath}}?rev={{urlquery .Name}}"><code>{{.Name}}</code></a>
88 <button type="button" class="iconbtn refcopy" data-copy="{{.Name}}" 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>
89 {{if .Default}}<span class="pill refbadge def">{{t "branch.default"}}</span>{{end}}
90 {{if .Protected}}<span class="pill refbadge">{{t "vis.protected"}}</span>{{end}}
91 </div>
92 <p class="refmeta">
93 {{if .SHA}}<a href="/{{.RepoPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a>{{end}}
94 {{if .Subject}}{{if .SHA}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="refsubject" title="{{.Subject}}">{{.Subject}}</span>{{end}}
95 {{if .When}}{{if or .SHA .Subject}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="muted when-short" title="{{.WhenTitle}}">{{.When}}</span>{{end}}
96 {{if .PipeStatus}}<a class="status {{.PipeStatus}}" href="/{{.RepoPath}}/-/pipelines/{{.PipeID}}"><span class="mark"></span>{{.PipeLabel}}</a>{{end}}
97 </p>
98 </div>
99 <div class="refacts">
100 {{if not .Default}}
101 {{if and (eq .Ahead 0) (eq .Behind 0)}}<span class="muted">{{t "branch.even"}}</span>{{else}}
102 {{if .Ahead}}<span class="addstat">{{t "branch.ahead" .Ahead}}</span>{{end}}
103 {{if .Behind}}<span class="delstat">{{t "branch.behind" .Behind}}</span>{{end}}
104 {{end}}
105 {{range .OpenMRs}}<a class="tiny" href="/{{$.RepoPath}}/-/merge-requests/{{.}}">!{{.}}</a>{{else}}
106 <a class="tiny" href="/{{$.RepoPath}}/-/merge-requests/new?source={{urlquery $.Name}}&amp;target={{urlquery $.Target}}">{{t "branch.makeMR"}}</a>
107 {{end}}
108 {{end}}
109 <details class="rowmenu">
110 <summary class="refdlbtn" aria-label="{{t "branch.download"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M7.25 2.25a.75.75 0 0 1 1.5 0v6.19l1.72-1.72a.75.75 0 1 1 1.06 1.06l-3 3a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 1 1 1.06-1.06l1.72 1.72V2.25zM3.75 12.5a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5z"/></svg></summary>
111 <div class="menu-panel refdl">
112 <a href="{{.ZipURL}}">{{t "tag.zip"}}</a>
113 <a href="{{.TarURL}}">{{t "tag.tgz"}}</a>
114 </div>
115 </details>
116 {{if .CanEdit}}
117 <button type="button" class="ghost tiny" data-delete="{{.Name}}">{{t "branch.delete"}}</button>
118 <details class="rowmenu tiny-menu">
119 <summary aria-label="{{t "branch.more"}}">⋯</summary>
120 <div class="menu-panel">
121 <button type="button" class="ghost" data-rename="{{.Name}}">{{t "branch.rename"}}</button>
122 </div>
123 </details>
124 {{end}}
125 </div>
126 </article>
127 {{end}}
@@ -1,71 +1,34 @@
1{{define "branches"}}
1{{define "branches"}}
2{{template "layout-start" .}}
2{{template "layout-start" .}}
3<header class="pagehead">
3<div class="refhead">
4 <h1>{{t "title.branches"}}</h1>
4 <nav class="reftabs" aria-label="{{t "branch.actions"}}">
5 <a href="/{{.Repo.FullPath}}/-/branches?state=overview"{{if eq .Branch.State "overview"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.overview"}}</a>
6 <a href="/{{.Repo.FullPath}}/-/branches?state=active"{{if eq .Branch.State "active"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.active"}}</a>
7 <a href="/{{.Repo.FullPath}}/-/branches?state=stale"{{if eq .Branch.State "stale"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.stale"}}</a>
8 <a href="/{{.Repo.FullPath}}/-/branches?state=all"{{if eq .Branch.State "all"}} class="on" aria-current="page"{{end}}>{{t "branch.tab.all"}}</a>
9 </nav>
5 {{if .CanWrite}}<button type="button" data-branch-open="create">{{t "branch.create"}}</button>{{end}}
10 {{if .CanWrite}}<button type="button" data-branch-open="create">{{t "branch.create"}}</button>{{end}}
6</header>
7<label class="branchsearch">{{t "branch.search"}}
8 <input type="search" data-branch-filter autocomplete="off" placeholder="{{t "branch.search"}}">
9</label>
10<div class="hscroll">
11<table class="branchtable">
12 <thead>
13 <tr>
14 <th>{{t "branch.name"}}</th>
15 <th>{{t "branch.last"}}</th>
16 <th>{{t "branch.compare"}}</th>
17 <th>{{t "mr.pipeline"}}</th>
18 <th>{{t "mr.title"}}</th>
19 <th>{{t "branch.actions"}}</th>
20 </tr>
21 </thead>
22 <tbody>
23 {{range .Branches}}
24 <tr data-branch-row data-name="{{.Name}}">
25 <td>
26 <a href="/{{$.Repo.FullPath}}?rev={{urlquery .Name}}">{{.Name}}</a>
27 {{if .Default}}<span class="pill">{{t "branch.default"}}</span>{{end}}
28 {{if .Protected}}<span class="pill">{{t "vis.protected"}}</span>{{end}}
29 </td>
30 <td>
31 {{if .SHA}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a> <span class="subject" title="{{.Subject}}">{{.Subject}}</span> <span class="muted when-short" title="{{.WhenTitle}}">{{.When}}</span>{{end}}
32 </td>
33 <td class="nums">
34 {{if and (eq .Ahead 0) (eq .Behind 0)}}<span class="muted">{{t "branch.even"}}</span>{{else}}
35 {{if .Ahead}}<span class="addstat">{{t "branch.ahead" .Ahead}}</span>{{end}}
36 {{if .Behind}}<span class="delstat">{{t "branch.behind" .Behind}}</span>{{end}}
37 {{end}}
38 </td>
39 <td>
40 {{if .PipeStatus}}<a class="status {{.PipeStatus}}" href="/{{$.Repo.FullPath}}/-/pipelines/{{.PipeID}}"><span class="mark"></span>{{.PipeLabel}}</a>{{end}}
41 </td>
42 <td class="mrlinks">
43 {{range .OpenMRs}}<a href="/{{$.Repo.FullPath}}/-/merge-requests/{{.}}">!{{.}}</a>{{end}}
44 </td>
45 <td class="branchacts">
46 <div class="branchline">
47 {{if not .Default}}
48 <a class="tiny" href="/{{$.Repo.FullPath}}/-/compare?from={{urlquery $.Repo.DefaultBranch}}&amp;to={{urlquery .Name}}">{{t "branch.compare"}}</a>
49 {{if not .OpenMRs}}<a class="tiny" href="/{{$.Repo.FullPath}}/-/merge-requests/new?source={{urlquery .Name}}&amp;target={{urlquery $.Repo.DefaultBranch}}">{{t "branch.mrShort"}}</a>{{end}}
50 {{end}}
51 {{if and $.CanWrite (not .Default) (not .Protected)}}
52 <details class="rowmenu tiny-menu">
53 <summary aria-label="{{t "branch.more"}}">⋯</summary>
54 <div class="menu-panel">
55 <button type="button" class="ghost" data-rename="{{.Name}}">{{t "branch.rename"}}</button>
56 <button type="button" class="ghost" data-delete="{{.Name}}">{{t "branch.delete"}}</button>
57 </div>
58 </details>
59 {{end}}
60 </div>
61 </td>
62 </tr>
63 {{else}}
64 <tr><td colspan="6" class="muted">{{t "repo.noBranches"}}</td></tr>
65 {{end}}
66 </tbody>
67</table>
68</div>
11</div>
12<label class="refsearch">
13 <input type="search" data-branch-filter autocomplete="off" placeholder="{{t "branch.filter"}}" aria-label="{{t "branch.filter"}}">
14 <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>
15</label>
16{{if and (not .Branch.Active) (not .Branch.Stale)}}
17<p class="muted">{{t "repo.noBranches"}}</p>
18{{else}}
19 {{if .Branch.ShowActive}}
20 <section class="refgroup" data-ref-group>
21 <h2>{{t "branch.group.active"}}</h2>
22 {{range .Branch.Active}}{{template "branchrow" .}}{{else}}<p class="muted refempty">{{t "branch.none.active"}}</p>{{end}}
23 </section>
24 {{end}}
25 {{if .Branch.ShowStale}}
26 <section class="refgroup" data-ref-group>
27 <h2>{{t "branch.group.stale"}}</h2>
28 {{range .Branch.Stale}}{{template "branchrow" .}}{{else}}<p class="muted refempty">{{t "branch.none.stale"}}</p>{{end}}
29 </section>
30 {{end}}
31{{end}}
69{{if .CanWrite}}
32{{if .CanWrite}}
70<dialog class="branch-dialog" data-branch-dialog="create">
33<dialog class="branch-dialog" data-branch-dialog="create">
71 <form method="post" action="/{{.Repo.FullPath}}/-/branches">
34 <form method="post" action="/{{.Repo.FullPath}}/-/branches">
@@ -112,7 +75,53 @@
112 </div>
75 </div>
113 </form>
76 </form>
114</dialog>
77</dialog>
115<script src="/assets/branch.js"></script>
116{{end}}
78{{end}}
79<script src="/assets/branch.js"></script>
117{{template "layout-end" .}}
80{{template "layout-end" .}}
118{{end}}
81{{end}}
82
83{{define "branchrow"}}
84<article class="refrow" data-branch-row data-name="{{.Name}}">
85 <div class="refmain">
86 <div class="refname">
87 <a href="/{{.RepoPath}}?rev={{urlquery .Name}}"><code>{{.Name}}</code></a>
88 <button type="button" class="iconbtn refcopy" data-copy="{{.Name}}" 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>
89 {{if .Default}}<span class="pill refbadge def">{{t "branch.default"}}</span>{{end}}
90 {{if .Protected}}<span class="pill refbadge">{{t "vis.protected"}}</span>{{end}}
91 </div>
92 <p class="refmeta">
93 {{if .SHA}}<a href="/{{.RepoPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a>{{end}}
94 {{if .Subject}}{{if .SHA}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="refsubject" title="{{.Subject}}">{{.Subject}}</span>{{end}}
95 {{if .When}}{{if or .SHA .Subject}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="muted when-short" title="{{.WhenTitle}}">{{.When}}</span>{{end}}
96 {{if .PipeStatus}}<a class="status {{.PipeStatus}}" href="/{{.RepoPath}}/-/pipelines/{{.PipeID}}"><span class="mark"></span>{{.PipeLabel}}</a>{{end}}
97 </p>
98 </div>
99 <div class="refacts">
100 {{if not .Default}}
101 {{if and (eq .Ahead 0) (eq .Behind 0)}}<span class="muted">{{t "branch.even"}}</span>{{else}}
102 {{if .Ahead}}<span class="addstat">{{t "branch.ahead" .Ahead}}</span>{{end}}
103 {{if .Behind}}<span class="delstat">{{t "branch.behind" .Behind}}</span>{{end}}
104 {{end}}
105 {{range .OpenMRs}}<a class="tiny" href="/{{$.RepoPath}}/-/merge-requests/{{.}}">!{{.}}</a>{{else}}
106 <a class="tiny" href="/{{$.RepoPath}}/-/merge-requests/new?source={{urlquery $.Name}}&amp;target={{urlquery $.Target}}">{{t "branch.makeMR"}}</a>
107 {{end}}
108 {{end}}
109 <details class="rowmenu">
110 <summary class="refdlbtn" aria-label="{{t "branch.download"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M7.25 2.25a.75.75 0 0 1 1.5 0v6.19l1.72-1.72a.75.75 0 1 1 1.06 1.06l-3 3a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 1 1 1.06-1.06l1.72 1.72V2.25zM3.75 12.5a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5z"/></svg></summary>
111 <div class="menu-panel refdl">
112 <a href="{{.ZipURL}}">{{t "tag.zip"}}</a>
113 <a href="{{.TarURL}}">{{t "tag.tgz"}}</a>
114 </div>
115 </details>
116 {{if .CanEdit}}
117 <button type="button" class="ghost tiny" data-delete="{{.Name}}">{{t "branch.delete"}}</button>
118 <details class="rowmenu tiny-menu">
119 <summary aria-label="{{t "branch.more"}}">⋯</summary>
120 <div class="menu-panel">
121 <button type="button" class="ghost" data-rename="{{.Name}}">{{t "branch.rename"}}</button>
122 </div>
123 </details>
124 {{end}}
125 </div>
126</article>
127{{end}}
internal/server/templates/collab.html +216 −95
@@ -1,110 +1,206 @@
1 1 {{define "mergeopts"}}
2 2 <div class="checks">
3 <label><input type="checkbox" name="remove_source_branch" value="1"{{if .MR.RemoveSourceBranch}} checked{{end}}> {{t "mr.remove.on"}}</label>
4 <label><input type="checkbox" name="squash" value="1"{{if .MR.Squash}} checked{{end}}> {{t "mr.squash.on"}}</label>
3 <label><input type="checkbox" name="remove_source_branch" value="1"{{if .MR.RemoveSourceBranch}} checked{{end}}> {{t "mr.remove.short"}}</label>
4 <label><input type="checkbox" name="squash" value="1"{{if .MR.Squash}} checked{{end}}> {{t "mr.squash.short"}}</label>
5 5 <label>{{t "mr.squash.message"}} <textarea name="squash_commit_message">{{if .MR.SquashMessage}}{{.MR.SquashMessage}}{{else}}{{.MR.Title}}{{end}}</textarea></label>
6 6 </div>
7 7 {{end}}
8 8
9 9 {{define "mrs"}}
10 10 {{template "layout-start" .}}
11 <header class="pagehead"><h1>{{t "mr.title"}}</h1></header>
12 {{if .CanWrite}}<p class="pageacts"><a class="btn" href="/{{.Repo.FullPath}}/-/merge-requests/new">{{t "mr.create"}}</a></p>{{end}}
13 <ul class="clean">
14 {{range .MRs}}<li><a href="/{{$.Repo.FullPath}}/-/merge-requests/{{.Number}}">!{{.Number}} {{.Title}}</a> <span class="pill">{{.Status}}</span>{{if .Draft}} <span class="pill">{{t "mr.draft"}}</span>{{end}} <span class="muted">{{.SourceBranch}} → {{.TargetBranch}}</span></li>{{else}}<li class="muted">{{t "mr.none"}}</li>{{end}}
15 </ul>
11 {{template "flowlist" .Flow}}
16 12 {{template "layout-end" .}}
17 13 {{end}}
18 14
15 {{define "flowlist"}}
16 <div class="flowhead">
17 <nav class="flowtabs" aria-label="{{t "list.tabs"}}">
18 {{range .Tabs}}<a href="{{.Href}}"{{if .On}} class="on" aria-current="page"{{end}}>{{t .Key}} <span class="flowcount">{{.Count}}</span></a>{{end}}
19 </nav>
20 {{if .CanNew}}<a class="btn" href="{{.NewHref}}">{{t .NewKey}}</a>{{end}}
21 </div>
22 <form class="flowbar" method="get" action="{{.Base}}">
23 <input type="hidden" name="state" value="{{.State}}">
24 <input type="hidden" name="dir" value="{{.Dir}}">
25 <div class="flowsearch">
26 <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>
27 <input name="q" value="{{.Query}}" placeholder="{{t "list.search"}}" aria-label="{{t "list.search"}}">
28 <button class="flowgo" type="submit">{{t "issue.filter"}}</button>
29 </div>
30 {{if .Filters}}
31 <select name="label" aria-label="{{t "issue.labels"}}" onchange="this.form.requestSubmit()">
32 <option value="">{{t "issue.anyLabel"}}</option>
33 {{range .Labels}}<option value="{{.Name}}"{{if eq .Name $.Label}} selected{{end}}>{{.Name}}</option>{{end}}
34 </select>
35 <select name="assignee" aria-label="{{t "issue.assignees"}}" onchange="this.form.requestSubmit()">
36 <option value="">{{t "issue.anyAssignee"}}</option>
37 {{range .People}}<option value="{{.Name}}"{{if eq .Name $.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}
38 </select>
39 {{end}}
40 <select name="sort" aria-label="{{t "list.sort"}}" onchange="this.form.requestSubmit()">
41 <option value="created"{{if eq .Sort "created"}} selected{{end}}>{{t "list.sort.created"}}</option>
42 <option value="updated"{{if eq .Sort "updated"}} selected{{end}}>{{t "list.sort.updated"}}</option>
43 </select>
44 <a class="btn ghost flowdir" href="{{.FlipHref}}" aria-label="{{if eq .Dir "asc"}}{{t "list.sort.desc"}}{{else}}{{t "list.sort.asc"}}{{end}}">
45 {{if eq .Dir "asc"}}
46 <svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 3.2 3.2 8.5h2.6V13h4.4V8.5h2.6L8 3.2z"/></svg>
47 {{else}}
48 <svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 12.8 12.8 7.5H10.2V3H5.8v4.5H3.2L8 12.8z"/></svg>
49 {{end}}
50 </a>
51 </form>
52 <ul class="flowlist">
53 {{range .Rows}}
54 <li class="flowrow">
55 <div class="flowmain">
56 <a class="flowtitle" href="{{.Href}}">{{if .Draft}}<span class="flowdraft">{{t "mr.draft"}}:</span> {{end}}<strong>{{.Title}}</strong></a>
57 <p class="flowmeta">
58 {{if .PipeHref}}<a class="flowpipe status {{.PipeStatus}}" href="{{.PipeHref}}" title="{{.PipeLabel}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}
59 <span class="flowref">{{.Ref}}</span>
60 <span class="flowdot" aria-hidden="true">·</span>
61 <span>{{t "list.created" .Created}}{{if .Author}} {{t "list.by"}} {{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{end}}</span>
62 {{if .Comments}}<span class="flowcomments" aria-label="{{tn .Comments "list.comment" "list.comments"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M2.2 2.4A1.4 1.4 0 0 1 3.6 1h8.8A1.4 1.4 0 0 1 13.8 2.4v6.4A1.4 1.4 0 0 1 12.4 10.2H8.1L4.6 13.4V10.2H3.6A1.4 1.4 0 0 1 2.2 8.8V2.4z"/></svg>{{.Comments}}</span>{{end}}
63 {{if .Target}}<span class="flowtarget">{{.Target}}</span>{{end}}
64 {{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
65 {{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
66 {{range .People}}{{if .URL}}<a href="{{.URL}}">{{.Name}}</a>{{else}}{{.Name}}{{end}} {{end}}
67 {{if .Extra}}<span>{{.Extra}}</span>{{end}}
68 </p>
69 </div>
70 <div class="flowside">
71 <span class="flowbadge {{.State}}">{{.StateLabel}}</span>
72 {{if .Updated}}<span class="flowupdated">{{t "list.updated" .Updated}}</span>{{end}}
73 </div>
74 </li>
75 {{else}}
76 <li class="flowempty muted">{{t .EmptyKey}}</li>
77 {{end}}
78 </ul>
79 {{end}}
80
19 81 {{define "mr"}}
20 82 {{template "layout-start" .}}
21 <header class="pagehead"><h1>!{{.MR.Number}} {{.MR.Title}}</h1></header>
22 <p>
23 <span class="pill">{{.MR.Status}}</span>
24 {{if .MR.Draft}}<span class="pill">{{t "mr.draft"}}</span>{{end}}
25 {{range .Labels}}<span class="pill">{{.}}</span>{{end}}
26 {{.MR.SourceBranch}} → {{.MR.TargetBranch}} · {{if .MR.Author}}<a href="/users/{{.MR.Author}}">{{.MR.Author}}</a>{{end}}
27 </p>
28 <h2>{{t "mr.pipeline"}}</h2>
29 {{if .MRPipe}}
30 {{$pipe := .MRPipe}}
31 <div class="mrpipe">
32 <a class="pipeid" href="/{{.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}">#{{$pipe.ID}}</a>
33 <span class="status {{$pipe.Status}}"><span class="mark"></span>{{$pipe.Label}}</span>
34 <div class="stages">
35 {{range $pipe.Stages}}
36 <span class="stage">
37 <button type="button" class="stage-dot {{.Status}}" data-stage="{{.Name}}" data-tip="{{.Tip}}" aria-label="{{.Tip}}"><span class="mark"></span></button>
38 <div class="stage-pop" popover="manual">
39 <strong>{{t "pipe.stage"}}: {{.Name}}</strong>
40 <ul>
41 {{range .Jobs}}<li data-job="{{.ID}}"><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}{{if .Queue}} <span class="queue" data-queue>{{.Queue}}</span>{{end}}</a></li>{{end}}
42 </ul>
83 <header class="mrhead">
84 <p class="mrbadges">
85 {{if .Banner}}<span class="mrstate {{.Banner.State}}">{{.Banner.StateLabel}}</span>{{else}}<span class="pill">{{.MR.Status}}</span>{{end}}
86 {{if .MR.Draft}}<span class="pill">{{t "mr.draft"}}</span>{{end}}
87 </p>
88 <h1>{{.MR.Title}}</h1>
89 <p class="mrmeta">!{{.MR.Number}}{{if .Banner}} · {{.Banner.WhenLabel}}{{end}}</p>
90 {{if .Banner}}
91 <p class="mrwant">
92 {{if .Banner.AuthorURL}}<a class="who" href="{{.Banner.AuthorURL}}">{{if .Banner.Avatar}}<img class="avatar sm" src="{{.Banner.Avatar}}" alt="">{{else}}<span class="avatar sm">{{.Banner.Initial}}</span>{{end}}{{.Banner.Author}}</a>{{else if .Banner.Author}}<span class="avatar sm">{{.Banner.Initial}}</span> <strong>{{.Banner.Author}}</strong>{{end}}
93 <span>{{t "mr.wantsLead"}}</span>
94 <strong>{{.Banner.CommitPhrase}}</strong>
95 <span>{{t "mr.wantsFrom"}}</span>
96 <span class="branchchip"><code>{{.MR.SourceBranch}}</code><button type="button" class="copy" data-copy="{{.MR.SourceBranch}}" aria-label="{{t "action.copy"}} {{.MR.SourceBranch}}">{{t "action.copy"}}</button></span>
97 <span>{{t "mr.wantsInto"}}</span>
98 <span class="branchchip"><code>{{.MR.TargetBranch}}</code><button type="button" class="copy" data-copy="{{.MR.TargetBranch}}" aria-label="{{t "action.copy"}} {{.MR.TargetBranch}}">{{t "action.copy"}}</button></span>
99 {{if ne (t "mr.wantsTail") "-"}}<span>{{t "mr.wantsTail"}}</span>{{end}}
100 </p>
101 {{end}}
102 {{if .Labels}}<p class="mrchips">{{range .Labels}}<span class="pill">{{.}}</span>{{end}}</p>{{end}}
103 </header>
104 <section class="mrwidget">
105 <div class="rowline">
106 <h2>{{t "mr.pipeline"}}</h2>
107 {{if .MRPipe}}
108 {{$pipe := .MRPipe}}
109 <div class="mrpipe" data-mr-pipe data-pipe="{{$pipe.ID}}"{{if $pipe.Live}} data-live="/{{.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}" data-live-on="1"{{end}}>
110 <a class="pipeid" href="/{{.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}">#{{$pipe.ID}}</a>
111 <span class="status {{$pipe.Status}}" data-pipe-status><span class="mark"></span><span data-pipe-label>{{$pipe.Label}}</span></span>
112 <div class="stages">
113 {{range $pipe.Stages}}
114 <span class="stage">
115 <button type="button" class="stage-dot {{.Status}}" data-stage="{{.Name}}" data-tip="{{.Tip}}" aria-label="{{.Tip}}"><span class="mark"></span></button>
116 <div class="stage-pop" popover="manual">
117 <strong>{{t "pipe.stage"}}: {{.Name}}</strong>
118 <ul>
119 {{range .Jobs}}<li data-job="{{.ID}}"><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}{{if .Queue}} <span class="queue" data-queue>{{.Queue}}</span>{{end}}</a></li>{{end}}
120 </ul>
121 </div>
122 </span>
123 {{end}}
43 124 </div>
44 </span>
45 {{end}}
125 {{template "pipe-retry" (dict "Can" .CanWrite "CSRF" .CSRF "Path" .Repo.FullPath "ID" $pipe.ID "Failed" $pipe.Failed "Back" (printf "/%s/-/merge-requests/%d" .Repo.FullPath .MR.Number))}}
126 </div>
127 {{else}}<span class="muted">{{t "mr.noPipeline"}}</span>{{end}}
46 128 </div>
47 </div>
48 {{else}}<p class="muted">{{t "mr.noPipeline"}}</p>{{end}}
49 {{if .MergeBlocks}}
50 <div class="mergewhy" role="status">
51 <p>{{t "mr.block.why"}}</p>
52 <ul>
53 {{range .MergeBlocks}}<li>{{.}}</li>{{end}}
54 </ul>
55 </div>
56 {{end}}
57 {{if and .CanMerge (not .MergeBlocks)}}
58 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
59 <input type="hidden" name="csrf" value="{{.CSRF}}">
60 {{template "mergeopts" .}}
61 <button type="submit">{{t "action.merge"}}</button>
62 </form>
63 {{end}}
64 {{if .CanForce}}
65 <form class="force-merge" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
66 <input type="hidden" name="csrf" value="{{.CSRF}}">
67 <input type="hidden" name="force" value="1">
68 <p class="flash bad">{{t "mr.force.warn"}}</p>
69 {{template "mergeopts" .}}
70 <label class="check"><input type="checkbox" name="confirm_force" value="1" required> {{t "mr.force.confirm"}}</label>
71 <button class="ghost" type="submit">{{t "mr.force"}}</button>
72 </form>
73 {{end}}
74 {{if .CanClose}}
75 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/close">
76 <input type="hidden" name="csrf" value="{{.CSRF}}"><button class="ghost" type="submit">{{t "action.close"}}</button>
77 </form>
78 {{end}}
79 {{if .CanReopen}}
80 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reopen">
81 <input type="hidden" name="csrf" value="{{.CSRF}}"><button type="submit">{{t "action.reopen"}}</button>
82 </form>
83 {{end}}
84 <h2>{{t "rev.title"}}</h2>
85 <ul class="clean">
86 {{range .Reviews}}<li><strong><a href="/users/{{.Username}}">{{.Username}}</a></strong> <span class="pill">{{.Label}}</span>
87 {{if and $.CanDismiss (or (eq .Status "changes") (eq .Status "rejected"))}}
88 <form method="post" action="/{{$.Repo.FullPath}}/-/merge-requests/{{$.MR.Number}}/reviews/dismiss">
89 <input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="user_id" value="{{.UserID}}">
90 <button class="ghost" type="submit">{{t "rev.dismiss"}}</button>
129 <div class="rowline">
130 <h2>{{t "rev.title"}}</h2>
131 <div class="revblock">
132 <ul class="mrreviews">
133 {{range .Reviews}}<li><strong><a href="/users/{{.Username}}">{{.Username}}</a></strong> <span class="pill">{{.Label}}</span>
134 {{if and $.CanDismiss (or (eq .Status "changes") (eq .Status "rejected"))}}
135 <form method="post" action="/{{$.Repo.FullPath}}/-/merge-requests/{{$.MR.Number}}/reviews/dismiss">
136 <input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="user_id" value="{{.UserID}}">
137 <button class="ghost" type="submit">{{t "rev.dismiss"}}</button>
138 </form>
139 {{end}}
140 </li>{{else}}<li class="muted">{{t "rev.none"}}</li>{{end}}
141 </ul>
142 {{if .CanReview}}
143 <form class="row" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reviews">
144 <input type="hidden" name="csrf" value="{{.CSRF}}">
145 {{if .CanApprove}}<button type="submit" name="status" value="approved">{{t "rev.approved"}}</button>{{end}}
146 <button type="submit" name="status" value="changes">{{t "rev.changes"}}</button>
147 <button class="ghost" type="submit" name="status" value="rejected">{{t "rev.rejected"}}</button>
148 </form>
149 {{end}}
150 </div>
151 </div>
152 <div class="rowline merge">
153 {{if and (eq .MR.Status "merged") .Banner}}
154 <p class="mergedby">
155 {{if .Banner.MergedBy}}{{t "mr.mergedByLead"}} {{if .Banner.MergedByURL}}<a href="{{.Banner.MergedByURL}}">{{.Banner.MergedBy}}</a>{{else}}<strong>{{.Banner.MergedBy}}</strong>{{end}} {{t "mr.mergedByOn"}} {{.Banner.MergedDate}}{{else}}{{t "mr.mergedOn" .Banner.MergedDate}}{{end}}
156 {{if .Banner.MergeShort}}<span class="branchchip"><code>{{.Banner.MergeShort}}</code><button type="button" class="copy" data-copy="{{.Banner.MergeSHA}}" aria-label="{{t "action.copy"}} {{.Banner.MergeShort}}">{{t "action.copy"}}</button></span>{{end}}
157 </p>
158 {{else}}
159 {{if .MergeBlocks}}
160 <div class="mergewhy" role="status">
161 <p>{{t "mr.block.why"}}</p>
162 <ul>
163 {{range .MergeBlocks}}<li>{{.}}</li>{{end}}
164 </ul>
165 </div>
166 {{end}}
167 {{if and .CanMerge (not .MergeBlocks)}}
168 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
169 <input type="hidden" name="csrf" value="{{.CSRF}}">
170 {{template "mergeopts" .}}
171 <button type="submit">{{t "action.merge"}}</button>
91 172 </form>
92 173 {{end}}
93 </li>{{else}}<li class="muted">{{t "rev.none"}}</li>{{end}}
94 </ul>
95 {{if .CanReview}}
96 <form class="row" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reviews">
97 <input type="hidden" name="csrf" value="{{.CSRF}}">
98 {{if .CanApprove}}<button type="submit" name="status" value="approved">{{t "rev.approved"}}</button>{{end}}
99 <button type="submit" name="status" value="changes">{{t "rev.changes"}}</button>
100 <button class="ghost" type="submit" name="status" value="rejected">{{t "rev.rejected"}}</button>
101 </form>
102 {{end}}
174 {{if .CanForce}}
175 <form class="force-merge" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
176 <input type="hidden" name="csrf" value="{{.CSRF}}">
177 <input type="hidden" name="force" value="1">
178 <p class="flash bad">{{t "mr.force.warn"}}</p>
179 {{template "mergeopts" .}}
180 <label class="check"><input type="checkbox" name="confirm_force" value="1" required> {{t "mr.force.confirm"}}</label>
181 <button class="ghost" type="submit">{{t "mr.force"}}</button>
182 </form>
183 {{end}}
184 <div class="mergeacts">
185 {{if .CanClose}}
186 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/close">
187 <input type="hidden" name="csrf" value="{{.CSRF}}"><button class="ghost" type="submit">{{t "action.close"}}</button>
188 </form>
189 {{end}}
190 {{if .CanReopen}}
191 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reopen">
192 <input type="hidden" name="csrf" value="{{.CSRF}}"><button type="submit">{{t "action.reopen"}}</button>
193 </form>
194 {{end}}
195 </div>
196 {{end}}
197 </div>
198 </section>
103 199 <p class="sub">
104 200 <a href="?tab=overview"{{if eq .Tab "overview"}} class="on"{{end}}>{{t "mr.overview"}}</a>
105 <a href="?tab=commits"{{if eq .Tab "commits"}} class="on"{{end}}>{{t "mr.commits"}}</a>
106 <a href="?tab=pipelines"{{if eq .Tab "pipelines"}} class="on"{{end}}>{{t "mr.pipelines"}}</a>
107 <a href="?tab=changes"{{if eq .Tab "changes"}} class="on"{{end}}>{{t "mr.changes"}}</a>
201 <a href="?tab=commits"{{if eq .Tab "commits"}} class="on"{{end}}>{{t "mr.commits"}}{{if .Banner}} <span class="count">{{.Banner.NCommits}}</span>{{end}}</a>
202 <a href="?tab=pipelines"{{if eq .Tab "pipelines"}} class="on"{{end}}>{{t "mr.pipelines"}}{{if .Banner}} <span class="count">{{.Banner.NPipes}}</span>{{end}}</a>
203 <a href="?tab=changes"{{if eq .Tab "changes"}} class="on"{{end}}>{{t "mr.changes"}}{{if .Banner}} <span class="count">{{.Banner.NChanges}}</span>{{end}}</a>
108 204 </p>
109 205 <section{{if ne .Tab "overview"}} hidden{{end}}>
110 206 {{if .MR.Description}}<div class="mdbody">{{.DescHTML}}</div>{{end}}
@@ -147,14 +243,14 @@
147 243 <section{{if ne .Tab "commits"}} hidden{{end}}>
148 244 <h2>{{t "mr.commits"}}</h2>
149 245 <ul class="clean">
150 {{range .Commits}}<li><a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a> <span class="muted"><code>{{.Short}}</code> {{.Author}}</span></li>{{else}}<li class="muted">{{t "mr.noDiff"}}</li>{{end}}
246 {{range .Commits}}<li><a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a> <span class="muted"><code>{{.Short}}</code> {{if .UserURL}}<a href="{{.UserURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}</span></li>{{else}}<li class="muted">{{t "mr.noDiff"}}</li>{{end}}
151 247 </ul>
152 248 </section>
153 249 <section{{if ne .Tab "pipelines"}} hidden{{end}}>
154 250 <h2>{{t "mr.pipelines"}}</h2>
155 251 {{if .PipeRows}}
156 252 <ul class="clean">
157 {{range .PipeRows}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a> <span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span></li>{{end}}
253 {{range .PipeRows}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a> <span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span> {{template "pipe-retry" (dict "Can" $.CanWrite "CSRF" $.CSRF "Path" $.Repo.FullPath "ID" .ID "Failed" .Failed "Back" (printf "/%s/-/merge-requests/%d" $.Repo.FullPath $.MR.Number))}}</li>{{end}}
158 254 </ul>
159 255 {{else}}<p class="muted">{{t "mr.noPipeline"}}</p>{{end}}
160 256 </section>
@@ -253,7 +349,7 @@
253 349 {{template "layout-start" .}}
254 350 <header class="pagehead"><h1>{{t "pipe.one"}} #{{.Pipe.ID}}</h1></header>
255 351 {{template "pipenav" .}}
256 <p><span class="status {{.PipeStatus}}" data-pipe-status><span class="mark"></span><span data-pipe-label>{{.PipeLabel}}</span></span>{{if .PipeSource}} <span class="pill">{{.PipeSource}}</span>{{end}} {{.Pipe.Ref}} <a href="/{{.Repo.FullPath}}/-/commit/{{.Pipe.CommitSHA}}"><code>{{.Pipe.CommitSHA}}</code></a></p>
352 <div class="pipehead" data-pipe="{{.Pipe.ID}}"><span class="status {{.PipeStatus}}" data-pipe-status><span class="mark"></span><span data-pipe-label>{{.PipeLabel}}</span></span>{{if .PipeSource}} <span class="pill">{{.PipeSource}}</span>{{end}} {{.Pipe.Ref}} <a href="/{{.Repo.FullPath}}/-/commit/{{.Pipe.CommitSHA}}"><code>{{.Pipe.CommitSHA}}</code></a> {{template "pipe-retry" (dict "Can" .CanWrite "CSRF" .CSRF "Path" .Repo.FullPath "ID" .Pipe.ID "Failed" .PipeFailed "Back" (printf "/%s/-/pipelines/%d" .Repo.FullPath .Pipe.ID))}}</div>
257 353 <p class="muted">{{t "pipe.runningOn" .RunnerName}}</p>
258 354 <ul class="clean"{{if .Live}} data-live="{{.LiveURL}}" data-live-on="1"{{end}}>
259 355 {{range .PipeJobs}}<li data-job="{{.ID}}"><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$.Pipe.ID}}/jobs/{{.ID}}">{{.Name}}</a> <span class="status {{.Status}}" data-job-status><span class="mark"></span><span data-job-label>{{.Label}}</span></span>{{if .Queue}} <span class="queue" data-queue>{{.Queue}}</span>{{end}} <span class="muted">{{.Stage}}</span></li>{{end}}
@@ -283,6 +379,7 @@
283 379 </td>
284 380 <td>{{if .Actor}}{{if .ActorURL}}<a class="avatarlink" href="{{.ActorURL}}">{{end}}{{if .Avatar}}<img class="avatar" src="{{.Avatar}}" alt="{{.Actor}}">{{else}}<span class="avatar">{{.Initial}}</span>{{end}}{{if .ActorURL}}</a>{{end}}{{end}}</td>
285 381 <td>
382 <div class="stagecell">
286 383 <div class="stages">
287 384 {{range .Stages}}
288 385 <span class="stage">
@@ -296,11 +393,35 @@
296 393 </span>
297 394 {{end}}
298 395 </div>
396 {{template "pipe-retry" (dict "Can" $.CanWrite "CSRF" $.CSRF "Path" $.Repo.FullPath "ID" .ID "Failed" .Failed "Back" (printf "/%s/-/pipelines" $.Repo.FullPath))}}
397 </div>
299 398 </td>
300 399 </tr>
301 400 {{end}}
302 401 {{end}}
303 402
403 {{define "pipe-retry"}}
404 {{if .Can}}
405 <details class="rowmenu piperetry">
406 <summary aria-label="{{t "pipe.retry"}}">{{t "pipe.retry"}}</summary>
407 <div class="menu-panel piperetry" data-pipe="{{.ID}}">
408 <form method="post" action="/{{.Path}}/-/pipelines/{{.ID}}/retry">
409 <input type="hidden" name="csrf" value="{{.CSRF}}">
410 <input type="hidden" name="mode" value="all">
411 <input type="hidden" name="back" value="{{.Back}}">
412 <button type="submit">{{t "pipe.retry.all"}}</button>
413 </form>
414 <form method="post" action="/{{.Path}}/-/pipelines/{{.ID}}/retry" data-retry-failed data-pipe="{{.ID}}"{{if not .Failed}} hidden{{end}}>
415 <input type="hidden" name="csrf" value="{{.CSRF}}">
416 <input type="hidden" name="mode" value="failed">
417 <input type="hidden" name="back" value="{{.Back}}">
418 <button type="submit">{{t "pipe.retry.failed"}}</button>
419 </form>
420 </div>
421 </details>
422 {{end}}
423 {{end}}
424
304 425 {{define "job"}}
305 426 {{template "layout-start" .}}
306 427 <header class="pagehead"><h1>{{with .JobPage}}{{.Name}}{{end}}</h1></header>
@@ -484,8 +605,8 @@
484 605 <button type="submit">{{t "action.save"}}</button>
485 606 </div>
486 607 </form>
487 <ul class="clean">
488 {{range .Members}}<li>{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} · {{roleName .Role}} {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}
608 <ul class="repolist">
609 {{range .Members}}<li>{{template "usermark" .}}<span class="grown">{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} <span class="muted">· {{roleName .Role}}</span> {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}</span>
489 610 {{if not .Pending}}<form method="post" action="/{{$.Repo.FullPath}}/-/members/remove"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="username" value="{{.Username}}"><button class="ghost" type="submit">{{t "action.remove"}}</button></form>{{end}}
490 611 </li>{{end}}
491 612 </ul>
@@ -740,7 +861,7 @@
740 861 </div>
741 862 </form>
742 863 {{end}}
743 <ul class="clean">{{range .Members}}<li>{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} · {{roleName .Role}} {{if eq .UserID $.Group.OwnerID}}<span class="pill">{{t "group.owner"}}</span>{{end}} {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}
864 <ul class="repolist">{{range .Members}}<li>{{template "usermark" .}}<span class="grown">{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} <span class="muted">· {{roleName .Role}}</span> {{if eq .UserID $.Group.OwnerID}}<span class="pill">{{t "group.owner"}}</span>{{end}} {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}</span>
744 865 {{if and $.CanAdmin (not .Pending) (ne .UserID $.Group.OwnerID)}}<form method="post" action="/groups/{{$.Group.Path}}/members/remove"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="username" value="{{.Username}}"><button class="ghost" type="submit">{{t "action.remove"}}</button></form>{{end}}
745 866 </li>{{end}}</ul>
746 867 {{else if eq .Tab "settings"}}
@@ -811,7 +932,7 @@
811 932 <ul class="repolist">
812 933 {{range .Cards}}
813 934 <li>
814 {{if .Repo.HasLogo}}<img class="tile" src="/{{.Repo.FullPath}}/-/logo" alt="">{{else}}<span class="tile">{{initial .Repo.Name}}</span>{{end}}
935 {{template "namemark" .Repo}}
815 936 <a class="reponame" href="/{{.Repo.FullPath}}">{{.Repo.Name}}</a>
816 937 {{template "visicon" .Repo.Visibility}}
817 938 <span class="stars" aria-label="{{t "group.star"}}">★ {{.Stars}}</span>
@@ -1,110 +1,206 @@
1{{define "mergeopts"}}
1{{define "mergeopts"}}
2<div class="checks">
2<div class="checks">
3 <label><input type="checkbox" name="remove_source_branch" value="1"{{if .MR.RemoveSourceBranch}} checked{{end}}> {{t "mr.remove.on"}}</label>
3 <label><input type="checkbox" name="remove_source_branch" value="1"{{if .MR.RemoveSourceBranch}} checked{{end}}> {{t "mr.remove.short"}}</label>
4 <label><input type="checkbox" name="squash" value="1"{{if .MR.Squash}} checked{{end}}> {{t "mr.squash.on"}}</label>
4 <label><input type="checkbox" name="squash" value="1"{{if .MR.Squash}} checked{{end}}> {{t "mr.squash.short"}}</label>
5 <label>{{t "mr.squash.message"}} <textarea name="squash_commit_message">{{if .MR.SquashMessage}}{{.MR.SquashMessage}}{{else}}{{.MR.Title}}{{end}}</textarea></label>
5 <label>{{t "mr.squash.message"}} <textarea name="squash_commit_message">{{if .MR.SquashMessage}}{{.MR.SquashMessage}}{{else}}{{.MR.Title}}{{end}}</textarea></label>
6</div>
6</div>
7{{end}}
7{{end}}
8
8
9{{define "mrs"}}
9{{define "mrs"}}
10{{template "layout-start" .}}
10{{template "layout-start" .}}
11<header class="pagehead"><h1>{{t "mr.title"}}</h1></header>
11{{template "flowlist" .Flow}}
12{{if .CanWrite}}<p class="pageacts"><a class="btn" href="/{{.Repo.FullPath}}/-/merge-requests/new">{{t "mr.create"}}</a></p>{{end}}
13<ul class="clean">
14 {{range .MRs}}<li><a href="/{{$.Repo.FullPath}}/-/merge-requests/{{.Number}}">!{{.Number}} {{.Title}}</a> <span class="pill">{{.Status}}</span>{{if .Draft}} <span class="pill">{{t "mr.draft"}}</span>{{end}} <span class="muted">{{.SourceBranch}} → {{.TargetBranch}}</span></li>{{else}}<li class="muted">{{t "mr.none"}}</li>{{end}}
15</ul>
16{{template "layout-end" .}}
12{{template "layout-end" .}}
17{{end}}
13{{end}}
18
14
15{{define "flowlist"}}
16<div class="flowhead">
17 <nav class="flowtabs" aria-label="{{t "list.tabs"}}">
18 {{range .Tabs}}<a href="{{.Href}}"{{if .On}} class="on" aria-current="page"{{end}}>{{t .Key}} <span class="flowcount">{{.Count}}</span></a>{{end}}
19 </nav>
20 {{if .CanNew}}<a class="btn" href="{{.NewHref}}">{{t .NewKey}}</a>{{end}}
21</div>
22<form class="flowbar" method="get" action="{{.Base}}">
23 <input type="hidden" name="state" value="{{.State}}">
24 <input type="hidden" name="dir" value="{{.Dir}}">
25 <div class="flowsearch">
26 <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>
27 <input name="q" value="{{.Query}}" placeholder="{{t "list.search"}}" aria-label="{{t "list.search"}}">
28 <button class="flowgo" type="submit">{{t "issue.filter"}}</button>
29 </div>
30 {{if .Filters}}
31 <select name="label" aria-label="{{t "issue.labels"}}" onchange="this.form.requestSubmit()">
32 <option value="">{{t "issue.anyLabel"}}</option>
33 {{range .Labels}}<option value="{{.Name}}"{{if eq .Name $.Label}} selected{{end}}>{{.Name}}</option>{{end}}
34 </select>
35 <select name="assignee" aria-label="{{t "issue.assignees"}}" onchange="this.form.requestSubmit()">
36 <option value="">{{t "issue.anyAssignee"}}</option>
37 {{range .People}}<option value="{{.Name}}"{{if eq .Name $.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}
38 </select>
39 {{end}}
40 <select name="sort" aria-label="{{t "list.sort"}}" onchange="this.form.requestSubmit()">
41 <option value="created"{{if eq .Sort "created"}} selected{{end}}>{{t "list.sort.created"}}</option>
42 <option value="updated"{{if eq .Sort "updated"}} selected{{end}}>{{t "list.sort.updated"}}</option>
43 </select>
44 <a class="btn ghost flowdir" href="{{.FlipHref}}" aria-label="{{if eq .Dir "asc"}}{{t "list.sort.desc"}}{{else}}{{t "list.sort.asc"}}{{end}}">
45 {{if eq .Dir "asc"}}
46 <svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 3.2 3.2 8.5h2.6V13h4.4V8.5h2.6L8 3.2z"/></svg>
47 {{else}}
48 <svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 12.8 12.8 7.5H10.2V3H5.8v4.5H3.2L8 12.8z"/></svg>
49 {{end}}
50 </a>
51</form>
52<ul class="flowlist">
53 {{range .Rows}}
54 <li class="flowrow">
55 <div class="flowmain">
56 <a class="flowtitle" href="{{.Href}}">{{if .Draft}}<span class="flowdraft">{{t "mr.draft"}}:</span> {{end}}<strong>{{.Title}}</strong></a>
57 <p class="flowmeta">
58 {{if .PipeHref}}<a class="flowpipe status {{.PipeStatus}}" href="{{.PipeHref}}" title="{{.PipeLabel}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}
59 <span class="flowref">{{.Ref}}</span>
60 <span class="flowdot" aria-hidden="true">·</span>
61 <span>{{t "list.created" .Created}}{{if .Author}} {{t "list.by"}} {{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{end}}</span>
62 {{if .Comments}}<span class="flowcomments" aria-label="{{tn .Comments "list.comment" "list.comments"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M2.2 2.4A1.4 1.4 0 0 1 3.6 1h8.8A1.4 1.4 0 0 1 13.8 2.4v6.4A1.4 1.4 0 0 1 12.4 10.2H8.1L4.6 13.4V10.2H3.6A1.4 1.4 0 0 1 2.2 8.8V2.4z"/></svg>{{.Comments}}</span>{{end}}
63 {{if .Target}}<span class="flowtarget">{{.Target}}</span>{{end}}
64 {{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
65 {{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
66 {{range .People}}{{if .URL}}<a href="{{.URL}}">{{.Name}}</a>{{else}}{{.Name}}{{end}} {{end}}
67 {{if .Extra}}<span>{{.Extra}}</span>{{end}}
68 </p>
69 </div>
70 <div class="flowside">
71 <span class="flowbadge {{.State}}">{{.StateLabel}}</span>
72 {{if .Updated}}<span class="flowupdated">{{t "list.updated" .Updated}}</span>{{end}}
73 </div>
74 </li>
75 {{else}}
76 <li class="flowempty muted">{{t .EmptyKey}}</li>
77 {{end}}
78</ul>
79{{end}}
80
19{{define "mr"}}
81{{define "mr"}}
20{{template "layout-start" .}}
82{{template "layout-start" .}}
21<header class="pagehead"><h1>!{{.MR.Number}} {{.MR.Title}}</h1></header>
83<header class="mrhead">
22<p>
84 <p class="mrbadges">
23 <span class="pill">{{.MR.Status}}</span>
85 {{if .Banner}}<span class="mrstate {{.Banner.State}}">{{.Banner.StateLabel}}</span>{{else}}<span class="pill">{{.MR.Status}}</span>{{end}}
24 {{if .MR.Draft}}<span class="pill">{{t "mr.draft"}}</span>{{end}}
86 {{if .MR.Draft}}<span class="pill">{{t "mr.draft"}}</span>{{end}}
25 {{range .Labels}}<span class="pill">{{.}}</span>{{end}}
87 </p>
26 {{.MR.SourceBranch}} → {{.MR.TargetBranch}} · {{if .MR.Author}}<a href="/users/{{.MR.Author}}">{{.MR.Author}}</a>{{end}}
88 <h1>{{.MR.Title}}</h1>
27</p>
89 <p class="mrmeta">!{{.MR.Number}}{{if .Banner}} · {{.Banner.WhenLabel}}{{end}}</p>
28<h2>{{t "mr.pipeline"}}</h2>
90 {{if .Banner}}
29{{if .MRPipe}}
91 <p class="mrwant">
30{{$pipe := .MRPipe}}
92 {{if .Banner.AuthorURL}}<a class="who" href="{{.Banner.AuthorURL}}">{{if .Banner.Avatar}}<img class="avatar sm" src="{{.Banner.Avatar}}" alt="">{{else}}<span class="avatar sm">{{.Banner.Initial}}</span>{{end}}{{.Banner.Author}}</a>{{else if .Banner.Author}}<span class="avatar sm">{{.Banner.Initial}}</span> <strong>{{.Banner.Author}}</strong>{{end}}
31<div class="mrpipe">
93 <span>{{t "mr.wantsLead"}}</span>
32 <a class="pipeid" href="/{{.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}">#{{$pipe.ID}}</a>
94 <strong>{{.Banner.CommitPhrase}}</strong>
33 <span class="status {{$pipe.Status}}"><span class="mark"></span>{{$pipe.Label}}</span>
95 <span>{{t "mr.wantsFrom"}}</span>
34 <div class="stages">
96 <span class="branchchip"><code>{{.MR.SourceBranch}}</code><button type="button" class="copy" data-copy="{{.MR.SourceBranch}}" aria-label="{{t "action.copy"}} {{.MR.SourceBranch}}">{{t "action.copy"}}</button></span>
35 {{range $pipe.Stages}}
97 <span>{{t "mr.wantsInto"}}</span>
36 <span class="stage">
98 <span class="branchchip"><code>{{.MR.TargetBranch}}</code><button type="button" class="copy" data-copy="{{.MR.TargetBranch}}" aria-label="{{t "action.copy"}} {{.MR.TargetBranch}}">{{t "action.copy"}}</button></span>
37 <button type="button" class="stage-dot {{.Status}}" data-stage="{{.Name}}" data-tip="{{.Tip}}" aria-label="{{.Tip}}"><span class="mark"></span></button>
99 {{if ne (t "mr.wantsTail") "-"}}<span>{{t "mr.wantsTail"}}</span>{{end}}
38 <div class="stage-pop" popover="manual">
100 </p>
39 <strong>{{t "pipe.stage"}}: {{.Name}}</strong>
101 {{end}}
40 <ul>
102 {{if .Labels}}<p class="mrchips">{{range .Labels}}<span class="pill">{{.}}</span>{{end}}</p>{{end}}
41 {{range .Jobs}}<li data-job="{{.ID}}"><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}{{if .Queue}} <span class="queue" data-queue>{{.Queue}}</span>{{end}}</a></li>{{end}}
103</header>
42 </ul>
104<section class="mrwidget">
105 <div class="rowline">
106 <h2>{{t "mr.pipeline"}}</h2>
107 {{if .MRPipe}}
108 {{$pipe := .MRPipe}}
109 <div class="mrpipe" data-mr-pipe data-pipe="{{$pipe.ID}}"{{if $pipe.Live}} data-live="/{{.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}" data-live-on="1"{{end}}>
110 <a class="pipeid" href="/{{.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}">#{{$pipe.ID}}</a>
111 <span class="status {{$pipe.Status}}" data-pipe-status><span class="mark"></span><span data-pipe-label>{{$pipe.Label}}</span></span>
112 <div class="stages">
113 {{range $pipe.Stages}}
114 <span class="stage">
115 <button type="button" class="stage-dot {{.Status}}" data-stage="{{.Name}}" data-tip="{{.Tip}}" aria-label="{{.Tip}}"><span class="mark"></span></button>
116 <div class="stage-pop" popover="manual">
117 <strong>{{t "pipe.stage"}}: {{.Name}}</strong>
118 <ul>
119 {{range .Jobs}}<li data-job="{{.ID}}"><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}{{if .Queue}} <span class="queue" data-queue>{{.Queue}}</span>{{end}}</a></li>{{end}}
120 </ul>
121 </div>
122 </span>
123 {{end}}
43 </div>
124 </div>
44 </span>
125 {{template "pipe-retry" (dict "Can" .CanWrite "CSRF" .CSRF "Path" .Repo.FullPath "ID" $pipe.ID "Failed" $pipe.Failed "Back" (printf "/%s/-/merge-requests/%d" .Repo.FullPath .MR.Number))}}
45 {{end}}
126 </div>
127 {{else}}<span class="muted">{{t "mr.noPipeline"}}</span>{{end}}
46 </div>
128 </div>
47</div>
129 <div class="rowline">
48{{else}}<p class="muted">{{t "mr.noPipeline"}}</p>{{end}}
130 <h2>{{t "rev.title"}}</h2>
49{{if .MergeBlocks}}
131 <div class="revblock">
50<div class="mergewhy" role="status">
132 <ul class="mrreviews">
51 <p>{{t "mr.block.why"}}</p>
133 {{range .Reviews}}<li><strong><a href="/users/{{.Username}}">{{.Username}}</a></strong> <span class="pill">{{.Label}}</span>
52 <ul>
134 {{if and $.CanDismiss (or (eq .Status "changes") (eq .Status "rejected"))}}
53 {{range .MergeBlocks}}<li>{{.}}</li>{{end}}
135 <form method="post" action="/{{$.Repo.FullPath}}/-/merge-requests/{{$.MR.Number}}/reviews/dismiss">
54 </ul>
136 <input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="user_id" value="{{.UserID}}">
55</div>
137 <button class="ghost" type="submit">{{t "rev.dismiss"}}</button>
56{{end}}
138 </form>
57{{if and .CanMerge (not .MergeBlocks)}}
139 {{end}}
58<form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
140 </li>{{else}}<li class="muted">{{t "rev.none"}}</li>{{end}}
59 <input type="hidden" name="csrf" value="{{.CSRF}}">
141 </ul>
60 {{template "mergeopts" .}}
142 {{if .CanReview}}
61 <button type="submit">{{t "action.merge"}}</button>
143 <form class="row" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reviews">
62</form>
144 <input type="hidden" name="csrf" value="{{.CSRF}}">
63{{end}}
145 {{if .CanApprove}}<button type="submit" name="status" value="approved">{{t "rev.approved"}}</button>{{end}}
64{{if .CanForce}}
146 <button type="submit" name="status" value="changes">{{t "rev.changes"}}</button>
65<form class="force-merge" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
147 <button class="ghost" type="submit" name="status" value="rejected">{{t "rev.rejected"}}</button>
66 <input type="hidden" name="csrf" value="{{.CSRF}}">
148 </form>
67 <input type="hidden" name="force" value="1">
149 {{end}}
68 <p class="flash bad">{{t "mr.force.warn"}}</p>
150 </div>
69 {{template "mergeopts" .}}
151 </div>
70 <label class="check"><input type="checkbox" name="confirm_force" value="1" required> {{t "mr.force.confirm"}}</label>
152 <div class="rowline merge">
71 <button class="ghost" type="submit">{{t "mr.force"}}</button>
153 {{if and (eq .MR.Status "merged") .Banner}}
72</form>
154 <p class="mergedby">
73{{end}}
155 {{if .Banner.MergedBy}}{{t "mr.mergedByLead"}} {{if .Banner.MergedByURL}}<a href="{{.Banner.MergedByURL}}">{{.Banner.MergedBy}}</a>{{else}}<strong>{{.Banner.MergedBy}}</strong>{{end}} {{t "mr.mergedByOn"}} {{.Banner.MergedDate}}{{else}}{{t "mr.mergedOn" .Banner.MergedDate}}{{end}}
74{{if .CanClose}}
156 {{if .Banner.MergeShort}}<span class="branchchip"><code>{{.Banner.MergeShort}}</code><button type="button" class="copy" data-copy="{{.Banner.MergeSHA}}" aria-label="{{t "action.copy"}} {{.Banner.MergeShort}}">{{t "action.copy"}}</button></span>{{end}}
75<form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/close">
157 </p>
76 <input type="hidden" name="csrf" value="{{.CSRF}}"><button class="ghost" type="submit">{{t "action.close"}}</button>
158 {{else}}
77</form>
159 {{if .MergeBlocks}}
78{{end}}
160 <div class="mergewhy" role="status">
79{{if .CanReopen}}
161 <p>{{t "mr.block.why"}}</p>
80<form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reopen">
162 <ul>
81 <input type="hidden" name="csrf" value="{{.CSRF}}"><button type="submit">{{t "action.reopen"}}</button>
163 {{range .MergeBlocks}}<li>{{.}}</li>{{end}}
82</form>
164 </ul>
83{{end}}
165 </div>
84<h2>{{t "rev.title"}}</h2>
166 {{end}}
85<ul class="clean">
167 {{if and .CanMerge (not .MergeBlocks)}}
86 {{range .Reviews}}<li><strong><a href="/users/{{.Username}}">{{.Username}}</a></strong> <span class="pill">{{.Label}}</span>
168 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
87 {{if and $.CanDismiss (or (eq .Status "changes") (eq .Status "rejected"))}}
169 <input type="hidden" name="csrf" value="{{.CSRF}}">
88 <form method="post" action="/{{$.Repo.FullPath}}/-/merge-requests/{{$.MR.Number}}/reviews/dismiss">
170 {{template "mergeopts" .}}
89 <input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="user_id" value="{{.UserID}}">
171 <button type="submit">{{t "action.merge"}}</button>
90 <button class="ghost" type="submit">{{t "rev.dismiss"}}</button>
91 </form>
172 </form>
92 {{end}}
173 {{end}}
93 </li>{{else}}<li class="muted">{{t "rev.none"}}</li>{{end}}
174 {{if .CanForce}}
94</ul>
175 <form class="force-merge" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/merge">
95{{if .CanReview}}
176 <input type="hidden" name="csrf" value="{{.CSRF}}">
96<form class="row" method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reviews">
177 <input type="hidden" name="force" value="1">
97 <input type="hidden" name="csrf" value="{{.CSRF}}">
178 <p class="flash bad">{{t "mr.force.warn"}}</p>
98 {{if .CanApprove}}<button type="submit" name="status" value="approved">{{t "rev.approved"}}</button>{{end}}
179 {{template "mergeopts" .}}
99 <button type="submit" name="status" value="changes">{{t "rev.changes"}}</button>
180 <label class="check"><input type="checkbox" name="confirm_force" value="1" required> {{t "mr.force.confirm"}}</label>
100 <button class="ghost" type="submit" name="status" value="rejected">{{t "rev.rejected"}}</button>
181 <button class="ghost" type="submit">{{t "mr.force"}}</button>
101</form>
182 </form>
102{{end}}
183 {{end}}
184 <div class="mergeacts">
185 {{if .CanClose}}
186 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/close">
187 <input type="hidden" name="csrf" value="{{.CSRF}}"><button class="ghost" type="submit">{{t "action.close"}}</button>
188 </form>
189 {{end}}
190 {{if .CanReopen}}
191 <form method="post" action="/{{.Repo.FullPath}}/-/merge-requests/{{.MR.Number}}/reopen">
192 <input type="hidden" name="csrf" value="{{.CSRF}}"><button type="submit">{{t "action.reopen"}}</button>
193 </form>
194 {{end}}
195 </div>
196 {{end}}
197 </div>
198</section>
103<p class="sub">
199<p class="sub">
104 <a href="?tab=overview"{{if eq .Tab "overview"}} class="on"{{end}}>{{t "mr.overview"}}</a>
200 <a href="?tab=overview"{{if eq .Tab "overview"}} class="on"{{end}}>{{t "mr.overview"}}</a>
105 <a href="?tab=commits"{{if eq .Tab "commits"}} class="on"{{end}}>{{t "mr.commits"}}</a>
201 <a href="?tab=commits"{{if eq .Tab "commits"}} class="on"{{end}}>{{t "mr.commits"}}{{if .Banner}} <span class="count">{{.Banner.NCommits}}</span>{{end}}</a>
106 <a href="?tab=pipelines"{{if eq .Tab "pipelines"}} class="on"{{end}}>{{t "mr.pipelines"}}</a>
202 <a href="?tab=pipelines"{{if eq .Tab "pipelines"}} class="on"{{end}}>{{t "mr.pipelines"}}{{if .Banner}} <span class="count">{{.Banner.NPipes}}</span>{{end}}</a>
107 <a href="?tab=changes"{{if eq .Tab "changes"}} class="on"{{end}}>{{t "mr.changes"}}</a>
203 <a href="?tab=changes"{{if eq .Tab "changes"}} class="on"{{end}}>{{t "mr.changes"}}{{if .Banner}} <span class="count">{{.Banner.NChanges}}</span>{{end}}</a>
108</p>
204</p>
109<section{{if ne .Tab "overview"}} hidden{{end}}>
205<section{{if ne .Tab "overview"}} hidden{{end}}>
110 {{if .MR.Description}}<div class="mdbody">{{.DescHTML}}</div>{{end}}
206 {{if .MR.Description}}<div class="mdbody">{{.DescHTML}}</div>{{end}}
@@ -147,14 +243,14 @@
147<section{{if ne .Tab "commits"}} hidden{{end}}>
243<section{{if ne .Tab "commits"}} hidden{{end}}>
148 <h2>{{t "mr.commits"}}</h2>
244 <h2>{{t "mr.commits"}}</h2>
149 <ul class="clean">
245 <ul class="clean">
150 {{range .Commits}}<li><a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a> <span class="muted"><code>{{.Short}}</code> {{.Author}}</span></li>{{else}}<li class="muted">{{t "mr.noDiff"}}</li>{{end}}
246 {{range .Commits}}<li><a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a> <span class="muted"><code>{{.Short}}</code> {{if .UserURL}}<a href="{{.UserURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}</span></li>{{else}}<li class="muted">{{t "mr.noDiff"}}</li>{{end}}
151 </ul>
247 </ul>
152</section>
248</section>
153<section{{if ne .Tab "pipelines"}} hidden{{end}}>
249<section{{if ne .Tab "pipelines"}} hidden{{end}}>
154 <h2>{{t "mr.pipelines"}}</h2>
250 <h2>{{t "mr.pipelines"}}</h2>
155 {{if .PipeRows}}
251 {{if .PipeRows}}
156 <ul class="clean">
252 <ul class="clean">
157 {{range .PipeRows}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a> <span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span></li>{{end}}
253 {{range .PipeRows}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a> <span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span> {{template "pipe-retry" (dict "Can" $.CanWrite "CSRF" $.CSRF "Path" $.Repo.FullPath "ID" .ID "Failed" .Failed "Back" (printf "/%s/-/merge-requests/%d" $.Repo.FullPath $.MR.Number))}}</li>{{end}}
158 </ul>
254 </ul>
159 {{else}}<p class="muted">{{t "mr.noPipeline"}}</p>{{end}}
255 {{else}}<p class="muted">{{t "mr.noPipeline"}}</p>{{end}}
160</section>
256</section>
@@ -253,7 +349,7 @@
253{{template "layout-start" .}}
349{{template "layout-start" .}}
254<header class="pagehead"><h1>{{t "pipe.one"}} #{{.Pipe.ID}}</h1></header>
350<header class="pagehead"><h1>{{t "pipe.one"}} #{{.Pipe.ID}}</h1></header>
255{{template "pipenav" .}}
351{{template "pipenav" .}}
256<p><span class="status {{.PipeStatus}}" data-pipe-status><span class="mark"></span><span data-pipe-label>{{.PipeLabel}}</span></span>{{if .PipeSource}} <span class="pill">{{.PipeSource}}</span>{{end}} {{.Pipe.Ref}} <a href="/{{.Repo.FullPath}}/-/commit/{{.Pipe.CommitSHA}}"><code>{{.Pipe.CommitSHA}}</code></a></p>
352<div class="pipehead" data-pipe="{{.Pipe.ID}}"><span class="status {{.PipeStatus}}" data-pipe-status><span class="mark"></span><span data-pipe-label>{{.PipeLabel}}</span></span>{{if .PipeSource}} <span class="pill">{{.PipeSource}}</span>{{end}} {{.Pipe.Ref}} <a href="/{{.Repo.FullPath}}/-/commit/{{.Pipe.CommitSHA}}"><code>{{.Pipe.CommitSHA}}</code></a> {{template "pipe-retry" (dict "Can" .CanWrite "CSRF" .CSRF "Path" .Repo.FullPath "ID" .Pipe.ID "Failed" .PipeFailed "Back" (printf "/%s/-/pipelines/%d" .Repo.FullPath .Pipe.ID))}}</div>
257<p class="muted">{{t "pipe.runningOn" .RunnerName}}</p>
353<p class="muted">{{t "pipe.runningOn" .RunnerName}}</p>
258<ul class="clean"{{if .Live}} data-live="{{.LiveURL}}" data-live-on="1"{{end}}>
354<ul class="clean"{{if .Live}} data-live="{{.LiveURL}}" data-live-on="1"{{end}}>
259{{range .PipeJobs}}<li data-job="{{.ID}}"><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$.Pipe.ID}}/jobs/{{.ID}}">{{.Name}}</a> <span class="status {{.Status}}" data-job-status><span class="mark"></span><span data-job-label>{{.Label}}</span></span>{{if .Queue}} <span class="queue" data-queue>{{.Queue}}</span>{{end}} <span class="muted">{{.Stage}}</span></li>{{end}}
355{{range .PipeJobs}}<li data-job="{{.ID}}"><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$.Pipe.ID}}/jobs/{{.ID}}">{{.Name}}</a> <span class="status {{.Status}}" data-job-status><span class="mark"></span><span data-job-label>{{.Label}}</span></span>{{if .Queue}} <span class="queue" data-queue>{{.Queue}}</span>{{end}} <span class="muted">{{.Stage}}</span></li>{{end}}
@@ -283,6 +379,7 @@
283 </td>
379 </td>
284 <td>{{if .Actor}}{{if .ActorURL}}<a class="avatarlink" href="{{.ActorURL}}">{{end}}{{if .Avatar}}<img class="avatar" src="{{.Avatar}}" alt="{{.Actor}}">{{else}}<span class="avatar">{{.Initial}}</span>{{end}}{{if .ActorURL}}</a>{{end}}{{end}}</td>
380 <td>{{if .Actor}}{{if .ActorURL}}<a class="avatarlink" href="{{.ActorURL}}">{{end}}{{if .Avatar}}<img class="avatar" src="{{.Avatar}}" alt="{{.Actor}}">{{else}}<span class="avatar">{{.Initial}}</span>{{end}}{{if .ActorURL}}</a>{{end}}{{end}}</td>
285 <td>
381 <td>
382 <div class="stagecell">
286 <div class="stages">
383 <div class="stages">
287 {{range .Stages}}
384 {{range .Stages}}
288 <span class="stage">
385 <span class="stage">
@@ -296,11 +393,35 @@
296 </span>
393 </span>
297 {{end}}
394 {{end}}
298 </div>
395 </div>
396 {{template "pipe-retry" (dict "Can" $.CanWrite "CSRF" $.CSRF "Path" $.Repo.FullPath "ID" .ID "Failed" .Failed "Back" (printf "/%s/-/pipelines" $.Repo.FullPath))}}
397 </div>
299 </td>
398 </td>
300</tr>
399</tr>
301{{end}}
400{{end}}
302{{end}}
401{{end}}
303
402
403{{define "pipe-retry"}}
404{{if .Can}}
405<details class="rowmenu piperetry">
406 <summary aria-label="{{t "pipe.retry"}}">{{t "pipe.retry"}}</summary>
407 <div class="menu-panel piperetry" data-pipe="{{.ID}}">
408 <form method="post" action="/{{.Path}}/-/pipelines/{{.ID}}/retry">
409 <input type="hidden" name="csrf" value="{{.CSRF}}">
410 <input type="hidden" name="mode" value="all">
411 <input type="hidden" name="back" value="{{.Back}}">
412 <button type="submit">{{t "pipe.retry.all"}}</button>
413 </form>
414 <form method="post" action="/{{.Path}}/-/pipelines/{{.ID}}/retry" data-retry-failed data-pipe="{{.ID}}"{{if not .Failed}} hidden{{end}}>
415 <input type="hidden" name="csrf" value="{{.CSRF}}">
416 <input type="hidden" name="mode" value="failed">
417 <input type="hidden" name="back" value="{{.Back}}">
418 <button type="submit">{{t "pipe.retry.failed"}}</button>
419 </form>
420 </div>
421</details>
422{{end}}
423{{end}}
424
304{{define "job"}}
425{{define "job"}}
305{{template "layout-start" .}}
426{{template "layout-start" .}}
306<header class="pagehead"><h1>{{with .JobPage}}{{.Name}}{{end}}</h1></header>
427<header class="pagehead"><h1>{{with .JobPage}}{{.Name}}{{end}}</h1></header>
@@ -484,8 +605,8 @@
484 <button type="submit">{{t "action.save"}}</button>
605 <button type="submit">{{t "action.save"}}</button>
485 </div>
606 </div>
486</form>
607</form>
487<ul class="clean">
608<ul class="repolist">
488 {{range .Members}}<li>{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} · {{roleName .Role}} {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}
609 {{range .Members}}<li>{{template "usermark" .}}<span class="grown">{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} <span class="muted">· {{roleName .Role}}</span> {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}</span>
489 {{if not .Pending}}<form method="post" action="/{{$.Repo.FullPath}}/-/members/remove"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="username" value="{{.Username}}"><button class="ghost" type="submit">{{t "action.remove"}}</button></form>{{end}}
610 {{if not .Pending}}<form method="post" action="/{{$.Repo.FullPath}}/-/members/remove"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="username" value="{{.Username}}"><button class="ghost" type="submit">{{t "action.remove"}}</button></form>{{end}}
490 </li>{{end}}
611 </li>{{end}}
491</ul>
612</ul>
@@ -740,7 +861,7 @@
740 </div>
861 </div>
741</form>
862</form>
742{{end}}
863{{end}}
743<ul class="clean">{{range .Members}}<li>{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} · {{roleName .Role}} {{if eq .UserID $.Group.OwnerID}}<span class="pill">{{t "group.owner"}}</span>{{end}} {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}
864<ul class="repolist">{{range .Members}}<li>{{template "usermark" .}}<span class="grown">{{if and (not .Pending) .UserID}}<a href="/users/{{.Username}}">{{.Username}}</a>{{else}}{{.Username}}{{end}} <span class="muted">· {{roleName .Role}}</span> {{if eq .UserID $.Group.OwnerID}}<span class="pill">{{t "group.owner"}}</span>{{end}} {{if .Pending}}<span class="pill">{{t "set.pending"}}</span>{{end}}</span>
744 {{if and $.CanAdmin (not .Pending) (ne .UserID $.Group.OwnerID)}}<form method="post" action="/groups/{{$.Group.Path}}/members/remove"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="username" value="{{.Username}}"><button class="ghost" type="submit">{{t "action.remove"}}</button></form>{{end}}
865 {{if and $.CanAdmin (not .Pending) (ne .UserID $.Group.OwnerID)}}<form method="post" action="/groups/{{$.Group.Path}}/members/remove"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="username" value="{{.Username}}"><button class="ghost" type="submit">{{t "action.remove"}}</button></form>{{end}}
745</li>{{end}}</ul>
866</li>{{end}}</ul>
746{{else if eq .Tab "settings"}}
867{{else if eq .Tab "settings"}}
@@ -811,7 +932,7 @@
811<ul class="repolist">
932<ul class="repolist">
812 {{range .Cards}}
933 {{range .Cards}}
813 <li>
934 <li>
814 {{if .Repo.HasLogo}}<img class="tile" src="/{{.Repo.FullPath}}/-/logo" alt="">{{else}}<span class="tile">{{initial .Repo.Name}}</span>{{end}}
935 {{template "namemark" .Repo}}
815 <a class="reponame" href="/{{.Repo.FullPath}}">{{.Repo.Name}}</a>
936 <a class="reponame" href="/{{.Repo.FullPath}}">{{.Repo.Name}}</a>
816 {{template "visicon" .Repo.Visibility}}
937 {{template "visicon" .Repo.Visibility}}
817 <span class="stars" aria-label="{{t "group.star"}}">★ {{.Stars}}</span>
938 <span class="stars" aria-label="{{t "group.star"}}">★ {{.Stars}}</span>
internal/server/templates/issues.html +3 −34
@@ -1,37 +1,6 @@
1 1 {{define "issues"}}
2 2 {{template "layout-start" .}}
3 <header class="pagehead"><h1>{{t "tab.issues"}}</h1></header>
4 {{if .Issues.CanCreate}}<p><a class="btn" href="/{{.Repo.FullPath}}/-/issues/new">{{t "issue.new"}}</a></p>{{end}}
5 <form class="row" method="get" action="/{{.Repo.FullPath}}/-/issues">
6 <input name="q" value="{{.Issues.Query}}" placeholder="{{t "issue.search"}}" aria-label="{{t "issue.search"}}">
7 <select name="state">
8 <option value="open"{{if eq .Issues.State "open"}} selected{{end}}>{{t "issue.open"}}</option>
9 <option value="closed"{{if eq .Issues.State "closed"}} selected{{end}}>{{t "issue.closed"}}</option>
10 <option value="all"{{if eq .Issues.State "all"}} selected{{end}}>{{t "issue.all"}}</option>
11 </select>
12 <select name="label">
13 <option value="">{{t "issue.anyLabel"}}</option>
14 {{range .Issues.Labels}}<option value="{{.Name}}"{{if eq .Name $.Issues.Label}} selected{{end}}>{{.Name}}</option>{{end}}
15 </select>
16 <select name="assignee">
17 <option value="">{{t "issue.anyAssignee"}}</option>
18 {{range .Issues.People}}<option value="{{.Name}}"{{if eq .Name $.Issues.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}
19 </select>
20 <button type="submit">{{t "issue.filter"}}</button>
21 </form>
22 <ul class="issuelist">
23 {{range .Issues.List}}
24 <li>
25 <a href="/{{$.Repo.FullPath}}/-/issues/{{.Number}}"><strong>#{{.Number}}</strong> {{.Title}}</a>
26 {{if eq .Status "closed"}}<span class="pill">{{t "issue.closed"}}</span>{{else}}<span class="pill">{{t "issue.open"}}</span>{{end}}
27 {{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
28 {{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
29 <span class="muted">{{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{if .Assignees}} · {{.Assignees}}{{end}}{{if .Milestone}} · {{.Milestone}}{{end}}{{if .Due}} · {{.Due}}{{end}}</span>
30 </li>
31 {{else}}
32 <li class="muted">{{t "issue.none"}}</li>
33 {{end}}
34 </ul>
3 {{template "flowlist" .Flow}}
35 4 {{if .CanAdmin}}
36 5 <h2>{{t "issue.addLabel"}}</h2>
37 6 <form class="row" method="post" action="/{{.Repo.FullPath}}/-/issues/labels">
@@ -94,7 +63,7 @@
94 63 </fieldset>
95 64 <fieldset class="checks">
96 65 <legend>{{t "issue.assignees"}}</legend>
97 {{range .Issues.People}}<label><input type="checkbox" name="assignee" value="{{.Name}}"{{if .On}} checked{{end}}> {{.Name}}</label>{{end}}
66 {{range .Issues.People}}<label class="pickrow"><input type="checkbox" name="assignee" value="{{.Name}}"{{if .On}} checked{{end}}> {{if .AvatarURL}}<img class="avatar" src="{{.AvatarURL}}" alt="">{{else}}<span class="avatar {{tileHue .Name}}">{{initial .Name}}</span>{{end}} {{.Name}}</label>{{end}}
98 67 </fieldset>
99 68 <label>{{t "issue.milestone"}}
100 69 <select name="milestone">
@@ -112,7 +81,7 @@
112 81 {{if eq .Issues.One.Status "closed"}}<span class="pill">{{t "issue.closed"}}</span>{{else}}<span class="pill">{{t "issue.open"}}</span>{{end}}
113 82 {{if .Issues.One.Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
114 83 {{range .Issues.One.Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
115 <span class="muted">{{t "issue.by"}} {{if .Issues.One.AuthorURL}}<a href="{{.Issues.One.AuthorURL}}">{{.Issues.One.Author}}</a>{{else}}{{.Issues.One.Author}}{{end}}{{if .Issues.One.Assignees}} · {{.Issues.One.Assignees}}{{end}}{{if .Issues.One.Milestone}} · {{.Issues.One.Milestone}}{{end}}{{if .Issues.One.Due}} · {{.Issues.One.Due}}{{end}}</span>
84 <span class="muted">{{t "issue.by"}} {{if .Issues.One.AuthorURL}}<a href="{{.Issues.One.AuthorURL}}">{{.Issues.One.Author}}</a>{{else}}{{.Issues.One.Author}}{{end}}{{range .Issues.One.People}} · {{if .URL}}<a href="{{.URL}}">{{.Name}}</a>{{else}}{{.Name}}{{end}}{{end}}{{if .Issues.One.Milestone}} · {{.Issues.One.Milestone}}{{end}}{{if .Issues.One.Due}} · {{.Issues.One.Due}}{{end}}</span>
116 85 </p>
117 86 <div class="mdbody">{{.Issues.One.HTML}}</div>
118 87 {{if .Issues.Related}}
@@ -1,37 +1,6 @@
1{{define "issues"}}
1{{define "issues"}}
2{{template "layout-start" .}}
2{{template "layout-start" .}}
3<header class="pagehead"><h1>{{t "tab.issues"}}</h1></header>
3{{template "flowlist" .Flow}}
4{{if .Issues.CanCreate}}<p><a class="btn" href="/{{.Repo.FullPath}}/-/issues/new">{{t "issue.new"}}</a></p>{{end}}
5<form class="row" method="get" action="/{{.Repo.FullPath}}/-/issues">
6 <input name="q" value="{{.Issues.Query}}" placeholder="{{t "issue.search"}}" aria-label="{{t "issue.search"}}">
7 <select name="state">
8 <option value="open"{{if eq .Issues.State "open"}} selected{{end}}>{{t "issue.open"}}</option>
9 <option value="closed"{{if eq .Issues.State "closed"}} selected{{end}}>{{t "issue.closed"}}</option>
10 <option value="all"{{if eq .Issues.State "all"}} selected{{end}}>{{t "issue.all"}}</option>
11 </select>
12 <select name="label">
13 <option value="">{{t "issue.anyLabel"}}</option>
14 {{range .Issues.Labels}}<option value="{{.Name}}"{{if eq .Name $.Issues.Label}} selected{{end}}>{{.Name}}</option>{{end}}
15 </select>
16 <select name="assignee">
17 <option value="">{{t "issue.anyAssignee"}}</option>
18 {{range .Issues.People}}<option value="{{.Name}}"{{if eq .Name $.Issues.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}
19 </select>
20 <button type="submit">{{t "issue.filter"}}</button>
21</form>
22<ul class="issuelist">
23 {{range .Issues.List}}
24 <li>
25 <a href="/{{$.Repo.FullPath}}/-/issues/{{.Number}}"><strong>#{{.Number}}</strong> {{.Title}}</a>
26 {{if eq .Status "closed"}}<span class="pill">{{t "issue.closed"}}</span>{{else}}<span class="pill">{{t "issue.open"}}</span>{{end}}
27 {{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
28 {{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
29 <span class="muted">{{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{if .Assignees}} · {{.Assignees}}{{end}}{{if .Milestone}} · {{.Milestone}}{{end}}{{if .Due}} · {{.Due}}{{end}}</span>
30 </li>
31 {{else}}
32 <li class="muted">{{t "issue.none"}}</li>
33 {{end}}
34</ul>
35{{if .CanAdmin}}
4{{if .CanAdmin}}
36<h2>{{t "issue.addLabel"}}</h2>
5<h2>{{t "issue.addLabel"}}</h2>
37<form class="row" method="post" action="/{{.Repo.FullPath}}/-/issues/labels">
6<form class="row" method="post" action="/{{.Repo.FullPath}}/-/issues/labels">
@@ -94,7 +63,7 @@
94</fieldset>
63</fieldset>
95<fieldset class="checks">
64<fieldset class="checks">
96 <legend>{{t "issue.assignees"}}</legend>
65 <legend>{{t "issue.assignees"}}</legend>
97 {{range .Issues.People}}<label><input type="checkbox" name="assignee" value="{{.Name}}"{{if .On}} checked{{end}}> {{.Name}}</label>{{end}}
66 {{range .Issues.People}}<label class="pickrow"><input type="checkbox" name="assignee" value="{{.Name}}"{{if .On}} checked{{end}}> {{if .AvatarURL}}<img class="avatar" src="{{.AvatarURL}}" alt="">{{else}}<span class="avatar {{tileHue .Name}}">{{initial .Name}}</span>{{end}} {{.Name}}</label>{{end}}
98</fieldset>
67</fieldset>
99<label>{{t "issue.milestone"}}
68<label>{{t "issue.milestone"}}
100 <select name="milestone">
69 <select name="milestone">
@@ -112,7 +81,7 @@
112 {{if eq .Issues.One.Status "closed"}}<span class="pill">{{t "issue.closed"}}</span>{{else}}<span class="pill">{{t "issue.open"}}</span>{{end}}
81 {{if eq .Issues.One.Status "closed"}}<span class="pill">{{t "issue.closed"}}</span>{{else}}<span class="pill">{{t "issue.open"}}</span>{{end}}
113 {{if .Issues.One.Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
82 {{if .Issues.One.Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
114 {{range .Issues.One.Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
83 {{range .Issues.One.Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
115 <span class="muted">{{t "issue.by"}} {{if .Issues.One.AuthorURL}}<a href="{{.Issues.One.AuthorURL}}">{{.Issues.One.Author}}</a>{{else}}{{.Issues.One.Author}}{{end}}{{if .Issues.One.Assignees}} · {{.Issues.One.Assignees}}{{end}}{{if .Issues.One.Milestone}} · {{.Issues.One.Milestone}}{{end}}{{if .Issues.One.Due}} · {{.Issues.One.Due}}{{end}}</span>
84 <span class="muted">{{t "issue.by"}} {{if .Issues.One.AuthorURL}}<a href="{{.Issues.One.AuthorURL}}">{{.Issues.One.Author}}</a>{{else}}{{.Issues.One.Author}}{{end}}{{range .Issues.One.People}} · {{if .URL}}<a href="{{.URL}}">{{.Name}}</a>{{else}}{{.Name}}{{end}}{{end}}{{if .Issues.One.Milestone}} · {{.Issues.One.Milestone}}{{end}}{{if .Issues.One.Due}} · {{.Issues.One.Due}}{{end}}</span>
116</p>
85</p>
117<div class="mdbody">{{.Issues.One.HTML}}</div>
86<div class="mdbody">{{.Issues.One.HTML}}</div>
118{{if .Issues.Related}}
87{{if .Issues.Related}}
internal/server/templates/layout.html +13 −5
@@ -46,7 +46,7 @@
46 46 <div class="frame{{if or .Repo .Group .Info .User}} with-side{{end}}">
47 47 {{if .Repo}}{{template "reposide" .}}{{else if .Group}}{{template "groupside" .}}{{else if .Info}}{{template "infoside" .}}{{else if .User}}{{template "dashside" .}}{{end}}
48 48 <div class="content">
49 <main{{if .Wide}} class="wide"{{end}}>
49 <main{{if eq .Page "files"}} class="fill"{{else if .Wide}} class="wide"{{end}}>
50 50 {{if .Notice}}<p class="flash">{{.Notice}}</p>{{end}}
51 51 {{if .Err}}<p class="flash bad">{{.Err}}</p>{{end}}
52 52 {{if .Repo}}
@@ -55,8 +55,8 @@
55 55 <p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a> <span aria-hidden="true">/</span> <span>{{.Group.Name}}</span></p>
56 56 {{else if .Profile}}
57 57 <p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a> <span aria-hidden="true">/</span> <span>{{.Profile.Username}}</span></p>
58 {{else if .User}}
59 <p class="crumbs"><span>{{t "nav.dashboard"}}</span></p>
58 {{else if and .User (ne .Page "dashboard")}}
59 <p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a></p>
60 60 {{end}}
61 61 {{end}}
62 62
@@ -73,7 +73,7 @@
73 73 {{define "reposide"}}
74 74 <aside class="sidenav">
75 75 <a class="sidecontext" href="/{{.Repo.FullPath}}{{if .Rev}}?rev={{.Rev}}{{end}}">
76 {{if .Repo.HasLogo}}<img class="tile" src="/{{.Repo.FullPath}}/-/logo" alt="">{{else}}<span class="tile">{{initial .Repo.Name}}</span>{{end}}
76 {{template "namemark" .Repo}}
77 77 <span class="sidename">{{.Repo.Name}}</span>
78 78 {{template "visicon" .Repo.Visibility}}
79 79 </a>
@@ -95,7 +95,7 @@
95 95 {{define "groupside"}}
96 96 <aside class="sidenav">
97 97 <a class="sidecontext" href="/groups/{{.Group.Path}}">
98 {{if .Group.HasLogo}}<img class="tile" src="/groups/{{.Group.Path}}/logo" alt="">{{else}}<span class="tile">{{initial .Group.Name}}</span>{{end}}
98 {{template "namemark" .Group}}
99 99 <span class="sidename">{{.Group.Name}}</span>
100 100 {{template "visicon" .Group.Visibility}}
101 101 </a>
@@ -120,6 +120,14 @@
120 120 </aside>
121 121 {{end}}
122 122
123 {{define "namemark"}}
124 {{if .LogoURL}}<img class="tile" src="{{.LogoURL}}" alt="">{{else}}<span class="tile {{tileHue .Name}}">{{initial .Name}}</span>{{end}}
125 {{end}}
126
127 {{define "usermark"}}
128 {{if .AvatarURL}}<img class="avatar" src="{{.AvatarURL}}" alt="">{{else}}<span class="avatar {{tileHue .Username}}">{{initial .Username}}</span>{{end}}
129 {{end}}
130
123 131 {{define "dashside"}}
124 132 <aside class="sidenav">
125 133 <a class="sidecontext" href="/users/{{.User.Username}}">
@@ -46,7 +46,7 @@
46<div class="frame{{if or .Repo .Group .Info .User}} with-side{{end}}">
46<div class="frame{{if or .Repo .Group .Info .User}} with-side{{end}}">
47{{if .Repo}}{{template "reposide" .}}{{else if .Group}}{{template "groupside" .}}{{else if .Info}}{{template "infoside" .}}{{else if .User}}{{template "dashside" .}}{{end}}
47{{if .Repo}}{{template "reposide" .}}{{else if .Group}}{{template "groupside" .}}{{else if .Info}}{{template "infoside" .}}{{else if .User}}{{template "dashside" .}}{{end}}
48<div class="content">
48<div class="content">
49<main{{if .Wide}} class="wide"{{end}}>
49<main{{if eq .Page "files"}} class="fill"{{else if .Wide}} class="wide"{{end}}>
50{{if .Notice}}<p class="flash">{{.Notice}}</p>{{end}}
50{{if .Notice}}<p class="flash">{{.Notice}}</p>{{end}}
51{{if .Err}}<p class="flash bad">{{.Err}}</p>{{end}}
51{{if .Err}}<p class="flash bad">{{.Err}}</p>{{end}}
52{{if .Repo}}
52{{if .Repo}}
@@ -55,8 +55,8 @@
55<p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a> <span aria-hidden="true">/</span> <span>{{.Group.Name}}</span></p>
55<p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a> <span aria-hidden="true">/</span> <span>{{.Group.Name}}</span></p>
56{{else if .Profile}}
56{{else if .Profile}}
57<p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a> <span aria-hidden="true">/</span> <span>{{.Profile.Username}}</span></p>
57<p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a> <span aria-hidden="true">/</span> <span>{{.Profile.Username}}</span></p>
58{{else if .User}}
58{{else if and .User (ne .Page "dashboard")}}
59<p class="crumbs"><span>{{t "nav.dashboard"}}</span></p>
59<p class="crumbs"><a href="/">{{t "nav.dashboard"}}</a></p>
60{{end}}
60{{end}}
61{{end}}
61{{end}}
62
62
@@ -73,7 +73,7 @@
73{{define "reposide"}}
73{{define "reposide"}}
74<aside class="sidenav">
74<aside class="sidenav">
75 <a class="sidecontext" href="/{{.Repo.FullPath}}{{if .Rev}}?rev={{.Rev}}{{end}}">
75 <a class="sidecontext" href="/{{.Repo.FullPath}}{{if .Rev}}?rev={{.Rev}}{{end}}">
76 {{if .Repo.HasLogo}}<img class="tile" src="/{{.Repo.FullPath}}/-/logo" alt="">{{else}}<span class="tile">{{initial .Repo.Name}}</span>{{end}}
76 {{template "namemark" .Repo}}
77 <span class="sidename">{{.Repo.Name}}</span>
77 <span class="sidename">{{.Repo.Name}}</span>
78 {{template "visicon" .Repo.Visibility}}
78 {{template "visicon" .Repo.Visibility}}
79 </a>
79 </a>
@@ -95,7 +95,7 @@
95{{define "groupside"}}
95{{define "groupside"}}
96<aside class="sidenav">
96<aside class="sidenav">
97 <a class="sidecontext" href="/groups/{{.Group.Path}}">
97 <a class="sidecontext" href="/groups/{{.Group.Path}}">
98 {{if .Group.HasLogo}}<img class="tile" src="/groups/{{.Group.Path}}/logo" alt="">{{else}}<span class="tile">{{initial .Group.Name}}</span>{{end}}
98 {{template "namemark" .Group}}
99 <span class="sidename">{{.Group.Name}}</span>
99 <span class="sidename">{{.Group.Name}}</span>
100 {{template "visicon" .Group.Visibility}}
100 {{template "visicon" .Group.Visibility}}
101 </a>
101 </a>
@@ -120,6 +120,14 @@
120</aside>
120</aside>
121{{end}}
121{{end}}
122
122
123{{define "namemark"}}
124{{if .LogoURL}}<img class="tile" src="{{.LogoURL}}" alt="">{{else}}<span class="tile {{tileHue .Name}}">{{initial .Name}}</span>{{end}}
125{{end}}
126
127{{define "usermark"}}
128{{if .AvatarURL}}<img class="avatar" src="{{.AvatarURL}}" alt="">{{else}}<span class="avatar {{tileHue .Username}}">{{initial .Username}}</span>{{end}}
129{{end}}
130
123{{define "dashside"}}
131{{define "dashside"}}
124<aside class="sidenav">
132<aside class="sidenav">
125 <a class="sidecontext" href="/users/{{.User.Username}}">
133 <a class="sidecontext" href="/users/{{.User.Username}}">
internal/server/templates/pages.html +127 −62
@@ -33,8 +33,8 @@
33 33 {{if .Repos}}
34 34 <section class="panel">
35 35 <h2>{{t "home.public"}}</h2>
36 <ul class="clean">
37 {{range .Repos}}<li><a href="/{{.FullPath}}">{{.FullPath}}</a> <span class="muted">{{.Description}}</span></li>{{end}}
36 <ul class="repolist">
37 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}">{{.FullPath}}</a>{{if .Description}} <span class="muted">{{.Description}}</span>{{end}}</div></li>{{end}}
38 38 </ul>
39 39 </section>
40 40 {{end}}
@@ -54,15 +54,15 @@
54 54 <section class="panel">
55 55 <h2>{{t "dash.repos"}}</h2>
56 56 {{if not .Repos}}<p class="muted">{{t "dash.noRepos"}}</p>{{end}}
57 <ul class="clean">
58 {{range .Repos}}<li><a href="/{{.FullPath}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</li>{{end}}
57 <ul class="repolist">
58 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</div></li>{{end}}
59 59 </ul>
60 60 </section>
61 61 <section class="panel">
62 62 <h2>{{t "dash.groups"}}</h2>
63 63 {{if not .Groups}}<p class="muted">{{t "dash.noGroups"}}</p>{{end}}
64 <ul class="clean">
65 {{range .Groups}}<li><a href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></li>{{end}}
64 <ul class="repolist">
65 {{range .Groups}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></div></li>{{end}}
66 66 </ul>
67 67 </section>
68 68 </div>
@@ -79,7 +79,7 @@
79 79 <ul class="repolist">
80 80 {{range .Repos}}
81 81 <li>
82 {{if .HasLogo}}<img class="tile" src="/{{.FullPath}}/-/logo" alt="">{{else}}<span class="tile">{{initial .Name}}</span>{{end}}
82 {{template "namemark" .}}
83 83 <a class="reponame" href="/{{.FullPath}}">{{.Name}}</a>
84 84 {{template "visicon" .Visibility}}
85 85 <span class="muted grown">{{.Description}}</span>
@@ -92,7 +92,7 @@
92 92 <ul class="repolist">
93 93 {{range .Groups}}
94 94 <li>
95 {{if .HasLogo}}<img class="tile" src="/groups/{{.Path}}/logo" alt="">{{else}}<span class="tile">{{initial .Name}}</span>{{end}}
95 {{template "namemark" .}}
96 96 <a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a>
97 97 {{template "visicon" .Visibility}}
98 98 <span class="muted grown">{{.Path}}</span>
@@ -168,12 +168,19 @@
168 168 <label>{{t "new.name"}} <input name="name" required autocomplete="off"></label>
169 169 <p class="preview"><span data-slug-text></span> <span data-slug-flag></span></p>
170 170 <label>{{t "new.description"}} <input name="description"></label>
171 <label>{{t "new.owner"}}
172 <select name="group">
173 <option value="">{{t "new.me"}}</option>
174 {{range .Groups}}<option value="{{.Path}}">{{.Name}}</option>{{end}}
175 </select>
176 </label>
171 <fieldset class="picklist">
172 <legend>{{t "new.owner"}}</legend>
173 <label>
174 <input type="radio" name="group" value="" checked>
175 {{if .User.AvatarURL}}<img class="avatar" src="{{.User.AvatarURL}}" alt="">{{else}}<span class="avatar {{tileHue .User.Username}}">{{initial .User.Username}}</span>{{end}}
176 <span>{{t "new.me"}}</span>
177 </label>
178 {{range .Groups}}<label>
179 <input type="radio" name="group" value="{{.Path}}">
180 {{template "namemark" .}}
181 <span>{{.Name}}</span>
182 </label>{{end}}
183 </fieldset>
177 184 <label>{{t "new.visibility"}}
178 185 <select name="visibility"><option value="private">{{t "vis.private"}}</option><option value="public">{{t "vis.public"}}</option></select>
179 186 </label>
@@ -348,11 +355,12 @@
348 355 <div class="muted">{{template "commitwho" .Head}} · {{.Head.When}}</div>
349 356 </div>
350 357 {{if and .Head.PipeStatus (eq .Page "overview")}}
351 <span class="headpipe" data-head-pipe{{if .Head.PipeLive}} data-live="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}" data-live-on="1"{{end}}>
358 <span class="headpipe" data-head-pipe data-pipe="{{.Head.PipeID}}"{{if .Head.PipeLive}} data-live="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}" data-live-on="1"{{end}}>
352 359 <a class="status {{.Head.PipeStatus}}" data-pipe-status href="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}"><span class="mark"></span><span data-pipe-label>{{.Head.PipeLabel}}</span></a>
353 360 <span class="muted" data-pipe-duration>{{.Head.PipeDuration}}</span>
354 361 {{template "stage-dots" .}}
355 362 </span>
363 {{template "pipe-retry" (dict "Can" .CanWrite "CSRF" .CSRF "Path" .Repo.FullPath "ID" .Head.PipeID "Failed" .Head.PipeFailed "Back" (printf "/%s" .Repo.FullPath))}}
356 364 {{else if .Head.PipeStatus}}<a class="status {{.Head.PipeStatus}}" href="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}"><span class="mark"></span>{{.Head.PipeLabel}}</a>{{end}}
357 365 <code class="sha">{{slice .Head.SHA 0 8}}</code>
358 366 <button type="button" class="iconbtn" data-copy="{{.Head.SHA}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>
@@ -509,54 +517,61 @@
509 517
510 518 {{define "tags"}}
511 519 {{template "layout-start" .}}
512 <header class="pagehead"><h1>{{t "title.tags"}}</h1></header>
513 <form class="bar" method="get" action="/{{.Repo.FullPath}}/-/tags">
520 <div class="refhead">
521 <h1>{{t "title.tags"}}</h1>
522 {{if .CanWrite}}<button type="button" data-tag-create>{{t "tag.create"}}</button>{{end}}
523 </div>
524 <form class="refsearch" method="get" action="/{{.Repo.FullPath}}/-/tags">
514 525 <input type="search" name="q" value="{{.Query}}" placeholder="{{t "tag.search"}}" aria-label="{{t "tag.search"}}">
526 <button class="refgo" type="submit" aria-label="{{t "tag.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>
515 527 </form>
516 {{if .CanWrite}}
517 <form class="panel" method="post" action="/{{.Repo.FullPath}}/-/tags">
518 <input type="hidden" name="csrf" value="{{.CSRF}}">
519 <div class="row">
520 <input name="name" placeholder="{{t "tag.name"}}" aria-label="{{t "tag.name"}}" required>
521 <input name="target" list="tag-targets" placeholder="{{t "tag.target"}}" aria-label="{{t "tag.target"}}" value="{{.Rev}}" required>
522 <input name="message" placeholder="{{t "tag.message"}}" aria-label="{{t "tag.message"}}">
523 <button type="submit">{{t "tag.create"}}</button>
524 </div>
525 </form>
526 <datalist id="tag-targets">{{range .Branches}}<option value="{{.Name}}"></option>{{end}}</datalist>
527 {{end}}
528 528 {{if .Tags}}
529 <div class="hscroll">
530 <table class="tags">
531 <thead>
532 <tr>
533 <th>{{t "tag.name"}}</th>
534 <th>{{t "tag.commit"}}</th>
535 <th>{{t "tag.date"}}</th>
536 <th>{{t "tag.message"}}</th>
537 <th></th>
538 </tr>
539 </thead>
540 <tbody>
541 {{range .Tags}}
542 <tr>
543 <td><code>{{.Name}}</code> {{if .Protected}}<span class="pill">{{t "vis.protected"}}</span>{{end}}</td>
544 <td>{{if .SHA}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code> {{.Subject}}</a>{{end}}</td>
545 <td>{{.Date}}</td>
546 <td>{{if .Annotated}}<span class="pill">{{t "tag.annotated"}}</span> {{if .Message}}<span class="tagmsg">{{.Message}}</span>{{end}}{{else}}<span class="muted">{{t "tag.lightweight"}}</span>{{end}}</td>
547 <td class="acts">
548 {{if .HasRelease}}<a href="/{{$.Repo.FullPath}}/-/releases#{{.Name}}">{{t "tag.release"}}</a>{{end}}
549 <a href="{{.ZipURL}}">{{t "tag.zip"}}</a>
550 <a href="{{.TarURL}}">{{t "tag.tgz"}}</a>
551 {{if .CanDelete}}<button type="button" class="ghost" data-tag-open data-tag="{{.Name}}">{{t "tag.delete"}}</button>{{end}}
552 </td>
553 </tr>
554 {{end}}
555 </tbody>
556 </table>
557 </div>
529 <section class="refgroup">
530 {{range .Tags}}
531 <article class="refrow">
532 <div class="refmain">
533 <div class="refname">
534 <code>{{.Name}}</code>
535 <button type="button" class="iconbtn refcopy" data-copy="{{.Name}}" 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>
536 {{if .Protected}}<span class="pill refbadge">{{t "vis.protected"}}</span>{{end}}
537 </div>
538 <p class="refmeta">
539 {{if .SHA}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a>{{end}}
540 {{if .Subject}}{{if .SHA}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="refsubject" title="{{.Subject}}">{{.Subject}}</span>{{end}}
541 {{if .When}}{{if or .SHA .Subject}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="muted when-short" title="{{.Date}}">{{.When}}</span>{{end}}
542 </p>
543 {{if .Annotated}}<p class="refnote"><span class="pill">{{t "tag.annotated"}}</span> {{.Message}}</p>{{else}}<p class="muted refnote">{{t "tag.lightweight"}}</p>{{end}}
544 {{if .HasRelease}}<p class="refnote"><a href="/{{$.Repo.FullPath}}/-/releases#{{.Name}}">{{t "tag.release"}}</a></p>{{end}}
545 </div>
546 <div class="refacts">
547 <details class="rowmenu">
548 <summary class="refdlbtn" aria-label="{{t "branch.download"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M7.25 2.25a.75.75 0 0 1 1.5 0v6.19l1.72-1.72a.75.75 0 1 1 1.06 1.06l-3 3a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 1 1 1.06-1.06l1.72 1.72V2.25zM3.75 12.5a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5z"/></svg></summary>
549 <div class="menu-panel refdl">
550 <a href="{{.ZipURL}}">{{t "tag.zip"}}</a>
551 <a href="{{.TarURL}}">{{t "tag.tgz"}}</a>
552 </div>
553 </details>
554 {{if .CanDelete}}<button type="button" class="ghost tiny" data-tag-open data-tag="{{.Name}}">{{t "tag.delete"}}</button>{{end}}
555 </div>
556 </article>
557 {{end}}
558 </section>
558 559 {{else if .Query}}<p class="muted">{{t "tag.noMatch"}}</p>{{else}}<p class="muted">{{t "repo.noTags"}}</p>{{end}}
559 560 {{if .CanWrite}}
561 <dialog class="branch-dialog" data-tag-form>
562 <form method="post" action="/{{.Repo.FullPath}}/-/tags">
563 <h2>{{t "tag.create"}}</h2>
564 <input type="hidden" name="csrf" value="{{.CSRF}}">
565 <label>{{t "tag.name"}} <input name="name" required autocomplete="off"></label>
566 <label>{{t "tag.target"}} <input name="target" list="tag-targets" value="{{.Rev}}" required></label>
567 <datalist id="tag-targets">{{range .Branches}}<option value="{{.Name}}"></option>{{end}}</datalist>
568 <label>{{t "tag.message"}} <input name="message" autocomplete="off"></label>
569 <div class="row">
570 <button type="submit">{{t "tag.create"}}</button>
571 <button type="button" class="ghost" data-tag-form-close>{{t "action.cancel"}}</button>
572 </div>
573 </form>
574 </dialog>
560 575 <dialog class="danger-modal" data-tag-dialog>
561 576 <form method="post" action="/{{.Repo.FullPath}}/-/tags/delete">
562 577 <input type="hidden" name="csrf" value="{{.CSRF}}">
@@ -575,10 +590,60 @@
575 590
576 591 {{define "commits"}}
577 592 {{template "layout-start" .}}
578 <header class="pagehead"><h1>{{t "title.commits"}}</h1></header>
579 <ul class="clean">
580 {{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}}
581 </ul>
593 <form class="clog" method="get" action="/{{.Repo.FullPath}}/-/commits">
594 <div class="clogref">
595 <label class="clogpick">
596 <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>
597 <select name="rev" data-rev aria-label="{{t "tab.branches"}}">
598 {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.Rev}} selected{{end}}>{{.Name}}</option>{{end}}
599 </select>
600 </label>
601 <a class="clogrepo" href="/{{.Repo.FullPath}}{{if .Rev}}?rev={{urlquery .Rev}}{{end}}">{{.Repo.Name}}</a>
602 </div>
603 <h1>{{t "title.commits"}}</h1>
604 <label class="clogsearch">
605 <input type="search" name="q" value="{{.Query}}" placeholder="{{t "commit.search"}}" aria-label="{{t "commit.search"}}" autocomplete="off">
606 <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>
607 </label>
608 </form>
609 {{if .CommitDays}}
610 {{range .CommitDays}}
611 <section class="cday">
612 <h2>{{.Label}}</h2>
613 {{range .Items}}
614 <article class="ccard" data-commit>
615 {{if .WhoURL}}<a class="avatarlink" href="{{.WhoURL}}">{{end}}
616 {{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}}
617 {{if .WhoURL}}</a>{{end}}
618 <div class="cmain">
619 <a class="csubject" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a>
620 <p class="cby">{{if .WhoURL}}<a href="{{.WhoURL}}">{{.Who}}</a>{{else}}{{.Who}}{{end}} {{t "commit.authoredWhen" .When}}</p>
621 </div>
622 <div class="cacts">
623 {{if .PipeStatus}}<a class="status {{.PipeStatus}} markonly" href="/{{$.Repo.FullPath}}/-/pipelines/{{.PipeID}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}
624 <code>{{if gt (len .SHA) 8}}{{slice .SHA 0 8}}{{else}}{{.SHA}}{{end}}</code>
625 <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>
626 <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>
627 <button type="button" class="iconbtn cchev" data-commit-toggle aria-expanded="false" aria-label="{{t "commit.expand"}}"></button>
628 </div>
629 <div class="cmsg" hidden>{{.Body}}</div>
630 </article>
631 {{end}}
632 </section>
633 {{end}}
634 {{if or .CommitPrev .CommitNext}}
635 <nav class="clogmore">
636 {{if .CommitPrev}}<a href="{{.CommitPrev}}">{{t "commit.prev"}}</a>{{end}}
637 {{if .CommitNext}}<a href="{{.CommitNext}}">{{t "commit.more"}}</a>{{end}}
638 </nav>
639 {{end}}
640 {{else if .Query}}
641 <p class="muted">{{t "commit.none"}}</p>
642 {{else}}
643 <p class="muted">{{t "repo.noCommits"}}</p>
644 {{end}}
645 <script src="/assets/commits.js"></script>
646 <script src="/assets/repo.js"></script>
582 647 {{template "layout-end" .}}
583 648 {{end}}
584 649
@@ -33,8 +33,8 @@
33{{if .Repos}}
33{{if .Repos}}
34<section class="panel">
34<section class="panel">
35 <h2>{{t "home.public"}}</h2>
35 <h2>{{t "home.public"}}</h2>
36 <ul class="clean">
36 <ul class="repolist">
37 {{range .Repos}}<li><a href="/{{.FullPath}}">{{.FullPath}}</a> <span class="muted">{{.Description}}</span></li>{{end}}
37 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}">{{.FullPath}}</a>{{if .Description}} <span class="muted">{{.Description}}</span>{{end}}</div></li>{{end}}
38 </ul>
38 </ul>
39</section>
39</section>
40{{end}}
40{{end}}
@@ -54,15 +54,15 @@
54 <section class="panel">
54 <section class="panel">
55 <h2>{{t "dash.repos"}}</h2>
55 <h2>{{t "dash.repos"}}</h2>
56 {{if not .Repos}}<p class="muted">{{t "dash.noRepos"}}</p>{{end}}
56 {{if not .Repos}}<p class="muted">{{t "dash.noRepos"}}</p>{{end}}
57 <ul class="clean">
57 <ul class="repolist">
58 {{range .Repos}}<li><a href="/{{.FullPath}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</li>{{end}}
58 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</div></li>{{end}}
59 </ul>
59 </ul>
60 </section>
60 </section>
61 <section class="panel">
61 <section class="panel">
62 <h2>{{t "dash.groups"}}</h2>
62 <h2>{{t "dash.groups"}}</h2>
63 {{if not .Groups}}<p class="muted">{{t "dash.noGroups"}}</p>{{end}}
63 {{if not .Groups}}<p class="muted">{{t "dash.noGroups"}}</p>{{end}}
64 <ul class="clean">
64 <ul class="repolist">
65 {{range .Groups}}<li><a href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></li>{{end}}
65 {{range .Groups}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></div></li>{{end}}
66 </ul>
66 </ul>
67 </section>
67 </section>
68</div>
68</div>
@@ -79,7 +79,7 @@
79 <ul class="repolist">
79 <ul class="repolist">
80 {{range .Repos}}
80 {{range .Repos}}
81 <li>
81 <li>
82 {{if .HasLogo}}<img class="tile" src="/{{.FullPath}}/-/logo" alt="">{{else}}<span class="tile">{{initial .Name}}</span>{{end}}
82 {{template "namemark" .}}
83 <a class="reponame" href="/{{.FullPath}}">{{.Name}}</a>
83 <a class="reponame" href="/{{.FullPath}}">{{.Name}}</a>
84 {{template "visicon" .Visibility}}
84 {{template "visicon" .Visibility}}
85 <span class="muted grown">{{.Description}}</span>
85 <span class="muted grown">{{.Description}}</span>
@@ -92,7 +92,7 @@
92 <ul class="repolist">
92 <ul class="repolist">
93 {{range .Groups}}
93 {{range .Groups}}
94 <li>
94 <li>
95 {{if .HasLogo}}<img class="tile" src="/groups/{{.Path}}/logo" alt="">{{else}}<span class="tile">{{initial .Name}}</span>{{end}}
95 {{template "namemark" .}}
96 <a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a>
96 <a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a>
97 {{template "visicon" .Visibility}}
97 {{template "visicon" .Visibility}}
98 <span class="muted grown">{{.Path}}</span>
98 <span class="muted grown">{{.Path}}</span>
@@ -168,12 +168,19 @@
168 <label>{{t "new.name"}} <input name="name" required autocomplete="off"></label>
168 <label>{{t "new.name"}} <input name="name" required autocomplete="off"></label>
169 <p class="preview"><span data-slug-text></span> <span data-slug-flag></span></p>
169 <p class="preview"><span data-slug-text></span> <span data-slug-flag></span></p>
170 <label>{{t "new.description"}} <input name="description"></label>
170 <label>{{t "new.description"}} <input name="description"></label>
171 <label>{{t "new.owner"}}
171 <fieldset class="picklist">
172 <select name="group">
172 <legend>{{t "new.owner"}}</legend>
173 <option value="">{{t "new.me"}}</option>
173 <label>
174 {{range .Groups}}<option value="{{.Path}}">{{.Name}}</option>{{end}}
174 <input type="radio" name="group" value="" checked>
175 </select>
175 {{if .User.AvatarURL}}<img class="avatar" src="{{.User.AvatarURL}}" alt="">{{else}}<span class="avatar {{tileHue .User.Username}}">{{initial .User.Username}}</span>{{end}}
176 </label>
176 <span>{{t "new.me"}}</span>
177 </label>
178 {{range .Groups}}<label>
179 <input type="radio" name="group" value="{{.Path}}">
180 {{template "namemark" .}}
181 <span>{{.Name}}</span>
182 </label>{{end}}
183 </fieldset>
177 <label>{{t "new.visibility"}}
184 <label>{{t "new.visibility"}}
178 <select name="visibility"><option value="private">{{t "vis.private"}}</option><option value="public">{{t "vis.public"}}</option></select>
185 <select name="visibility"><option value="private">{{t "vis.private"}}</option><option value="public">{{t "vis.public"}}</option></select>
179 </label>
186 </label>
@@ -348,11 +355,12 @@
348 <div class="muted">{{template "commitwho" .Head}} · {{.Head.When}}</div>
355 <div class="muted">{{template "commitwho" .Head}} · {{.Head.When}}</div>
349 </div>
356 </div>
350 {{if and .Head.PipeStatus (eq .Page "overview")}}
357 {{if and .Head.PipeStatus (eq .Page "overview")}}
351 <span class="headpipe" data-head-pipe{{if .Head.PipeLive}} data-live="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}" data-live-on="1"{{end}}>
358 <span class="headpipe" data-head-pipe data-pipe="{{.Head.PipeID}}"{{if .Head.PipeLive}} data-live="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}" data-live-on="1"{{end}}>
352 <a class="status {{.Head.PipeStatus}}" data-pipe-status href="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}"><span class="mark"></span><span data-pipe-label>{{.Head.PipeLabel}}</span></a>
359 <a class="status {{.Head.PipeStatus}}" data-pipe-status href="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}"><span class="mark"></span><span data-pipe-label>{{.Head.PipeLabel}}</span></a>
353 <span class="muted" data-pipe-duration>{{.Head.PipeDuration}}</span>
360 <span class="muted" data-pipe-duration>{{.Head.PipeDuration}}</span>
354 {{template "stage-dots" .}}
361 {{template "stage-dots" .}}
355 </span>
362 </span>
363 {{template "pipe-retry" (dict "Can" .CanWrite "CSRF" .CSRF "Path" .Repo.FullPath "ID" .Head.PipeID "Failed" .Head.PipeFailed "Back" (printf "/%s" .Repo.FullPath))}}
356 {{else if .Head.PipeStatus}}<a class="status {{.Head.PipeStatus}}" href="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}"><span class="mark"></span>{{.Head.PipeLabel}}</a>{{end}}
364 {{else if .Head.PipeStatus}}<a class="status {{.Head.PipeStatus}}" href="/{{.Repo.FullPath}}/-/pipelines/{{.Head.PipeID}}"><span class="mark"></span>{{.Head.PipeLabel}}</a>{{end}}
357 <code class="sha">{{slice .Head.SHA 0 8}}</code>
365 <code class="sha">{{slice .Head.SHA 0 8}}</code>
358 <button type="button" class="iconbtn" data-copy="{{.Head.SHA}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>
366 <button type="button" class="iconbtn" data-copy="{{.Head.SHA}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>
@@ -509,54 +517,61 @@
509
517
510{{define "tags"}}
518{{define "tags"}}
511{{template "layout-start" .}}
519{{template "layout-start" .}}
512<header class="pagehead"><h1>{{t "title.tags"}}</h1></header>
520<div class="refhead">
513<form class="bar" method="get" action="/{{.Repo.FullPath}}/-/tags">
521 <h1>{{t "title.tags"}}</h1>
522 {{if .CanWrite}}<button type="button" data-tag-create>{{t "tag.create"}}</button>{{end}}
523</div>
524<form class="refsearch" method="get" action="/{{.Repo.FullPath}}/-/tags">
514 <input type="search" name="q" value="{{.Query}}" placeholder="{{t "tag.search"}}" aria-label="{{t "tag.search"}}">
525 <input type="search" name="q" value="{{.Query}}" placeholder="{{t "tag.search"}}" aria-label="{{t "tag.search"}}">
526 <button class="refgo" type="submit" aria-label="{{t "tag.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>
515</form>
527</form>
516{{if .CanWrite}}
517<form class="panel" method="post" action="/{{.Repo.FullPath}}/-/tags">
518 <input type="hidden" name="csrf" value="{{.CSRF}}">
519 <div class="row">
520 <input name="name" placeholder="{{t "tag.name"}}" aria-label="{{t "tag.name"}}" required>
521 <input name="target" list="tag-targets" placeholder="{{t "tag.target"}}" aria-label="{{t "tag.target"}}" value="{{.Rev}}" required>
522 <input name="message" placeholder="{{t "tag.message"}}" aria-label="{{t "tag.message"}}">
523 <button type="submit">{{t "tag.create"}}</button>
524 </div>
525</form>
526<datalist id="tag-targets">{{range .Branches}}<option value="{{.Name}}"></option>{{end}}</datalist>
527{{end}}
528{{if .Tags}}
528{{if .Tags}}
529<div class="hscroll">
529<section class="refgroup">
530<table class="tags">
530 {{range .Tags}}
531 <thead>
531 <article class="refrow">
532 <tr>
532 <div class="refmain">
533 <th>{{t "tag.name"}}</th>
533 <div class="refname">
534 <th>{{t "tag.commit"}}</th>
534 <code>{{.Name}}</code>
535 <th>{{t "tag.date"}}</th>
535 <button type="button" class="iconbtn refcopy" data-copy="{{.Name}}" 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>
536 <th>{{t "tag.message"}}</th>
536 {{if .Protected}}<span class="pill refbadge">{{t "vis.protected"}}</span>{{end}}
537 <th></th>
537 </div>
538 </tr>
538 <p class="refmeta">
539 </thead>
539 {{if .SHA}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a>{{end}}
540 <tbody>
540 {{if .Subject}}{{if .SHA}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="refsubject" title="{{.Subject}}">{{.Subject}}</span>{{end}}
541 {{range .Tags}}
541 {{if .When}}{{if or .SHA .Subject}}<span class="refdot" aria-hidden="true">·</span>{{end}}<span class="muted when-short" title="{{.Date}}">{{.When}}</span>{{end}}
542 <tr>
542 </p>
543 <td><code>{{.Name}}</code> {{if .Protected}}<span class="pill">{{t "vis.protected"}}</span>{{end}}</td>
543 {{if .Annotated}}<p class="refnote"><span class="pill">{{t "tag.annotated"}}</span> {{.Message}}</p>{{else}}<p class="muted refnote">{{t "tag.lightweight"}}</p>{{end}}
544 <td>{{if .SHA}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code> {{.Subject}}</a>{{end}}</td>
544 {{if .HasRelease}}<p class="refnote"><a href="/{{$.Repo.FullPath}}/-/releases#{{.Name}}">{{t "tag.release"}}</a></p>{{end}}
545 <td>{{.Date}}</td>
545 </div>
546 <td>{{if .Annotated}}<span class="pill">{{t "tag.annotated"}}</span> {{if .Message}}<span class="tagmsg">{{.Message}}</span>{{end}}{{else}}<span class="muted">{{t "tag.lightweight"}}</span>{{end}}</td>
546 <div class="refacts">
547 <td class="acts">
547 <details class="rowmenu">
548 {{if .HasRelease}}<a href="/{{$.Repo.FullPath}}/-/releases#{{.Name}}">{{t "tag.release"}}</a>{{end}}
548 <summary class="refdlbtn" aria-label="{{t "branch.download"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M7.25 2.25a.75.75 0 0 1 1.5 0v6.19l1.72-1.72a.75.75 0 1 1 1.06 1.06l-3 3a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 1 1 1.06-1.06l1.72 1.72V2.25zM3.75 12.5a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5z"/></svg></summary>
549 <a href="{{.ZipURL}}">{{t "tag.zip"}}</a>
549 <div class="menu-panel refdl">
550 <a href="{{.TarURL}}">{{t "tag.tgz"}}</a>
550 <a href="{{.ZipURL}}">{{t "tag.zip"}}</a>
551 {{if .CanDelete}}<button type="button" class="ghost" data-tag-open data-tag="{{.Name}}">{{t "tag.delete"}}</button>{{end}}
551 <a href="{{.TarURL}}">{{t "tag.tgz"}}</a>
552 </td>
552 </div>
553 </tr>
553 </details>
554 {{end}}
554 {{if .CanDelete}}<button type="button" class="ghost tiny" data-tag-open data-tag="{{.Name}}">{{t "tag.delete"}}</button>{{end}}
555 </tbody>
555 </div>
556</table>
556 </article>
557</div>
557 {{end}}
558</section>
558{{else if .Query}}<p class="muted">{{t "tag.noMatch"}}</p>{{else}}<p class="muted">{{t "repo.noTags"}}</p>{{end}}
559{{else if .Query}}<p class="muted">{{t "tag.noMatch"}}</p>{{else}}<p class="muted">{{t "repo.noTags"}}</p>{{end}}
559{{if .CanWrite}}
560{{if .CanWrite}}
561<dialog class="branch-dialog" data-tag-form>
562 <form method="post" action="/{{.Repo.FullPath}}/-/tags">
563 <h2>{{t "tag.create"}}</h2>
564 <input type="hidden" name="csrf" value="{{.CSRF}}">
565 <label>{{t "tag.name"}} <input name="name" required autocomplete="off"></label>
566 <label>{{t "tag.target"}} <input name="target" list="tag-targets" value="{{.Rev}}" required></label>
567 <datalist id="tag-targets">{{range .Branches}}<option value="{{.Name}}"></option>{{end}}</datalist>
568 <label>{{t "tag.message"}} <input name="message" autocomplete="off"></label>
569 <div class="row">
570 <button type="submit">{{t "tag.create"}}</button>
571 <button type="button" class="ghost" data-tag-form-close>{{t "action.cancel"}}</button>
572 </div>
573 </form>
574</dialog>
560<dialog class="danger-modal" data-tag-dialog>
575<dialog class="danger-modal" data-tag-dialog>
561 <form method="post" action="/{{.Repo.FullPath}}/-/tags/delete">
576 <form method="post" action="/{{.Repo.FullPath}}/-/tags/delete">
562 <input type="hidden" name="csrf" value="{{.CSRF}}">
577 <input type="hidden" name="csrf" value="{{.CSRF}}">
@@ -575,10 +590,60 @@
575
590
576{{define "commits"}}
591{{define "commits"}}
577{{template "layout-start" .}}
592{{template "layout-start" .}}
578<header class="pagehead"><h1>{{t "title.commits"}}</h1></header>
593<form class="clog" method="get" action="/{{.Repo.FullPath}}/-/commits">
579<ul class="clean">
594 <div class="clogref">
580 {{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}}
595 <label class="clogpick">
581</ul>
596 <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>
597 <select name="rev" data-rev aria-label="{{t "tab.branches"}}">
598 {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.Rev}} selected{{end}}>{{.Name}}</option>{{end}}
599 </select>
600 </label>
601 <a class="clogrepo" href="/{{.Repo.FullPath}}{{if .Rev}}?rev={{urlquery .Rev}}{{end}}">{{.Repo.Name}}</a>
602 </div>
603 <h1>{{t "title.commits"}}</h1>
604 <label class="clogsearch">
605 <input type="search" name="q" value="{{.Query}}" placeholder="{{t "commit.search"}}" aria-label="{{t "commit.search"}}" autocomplete="off">
606 <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>
607 </label>
608</form>
609{{if .CommitDays}}
610 {{range .CommitDays}}
611 <section class="cday">
612 <h2>{{.Label}}</h2>
613 {{range .Items}}
614 <article class="ccard" data-commit>
615 {{if .WhoURL}}<a class="avatarlink" href="{{.WhoURL}}">{{end}}
616 {{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}}
617 {{if .WhoURL}}</a>{{end}}
618 <div class="cmain">
619 <a class="csubject" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Subject}}</a>
620 <p class="cby">{{if .WhoURL}}<a href="{{.WhoURL}}">{{.Who}}</a>{{else}}{{.Who}}{{end}} {{t "commit.authoredWhen" .When}}</p>
621 </div>
622 <div class="cacts">
623 {{if .PipeStatus}}<a class="status {{.PipeStatus}} markonly" href="/{{$.Repo.FullPath}}/-/pipelines/{{.PipeID}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}
624 <code>{{if gt (len .SHA) 8}}{{slice .SHA 0 8}}{{else}}{{.SHA}}{{end}}</code>
625 <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>
626 <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>
627 <button type="button" class="iconbtn cchev" data-commit-toggle aria-expanded="false" aria-label="{{t "commit.expand"}}"></button>
628 </div>
629 <div class="cmsg" hidden>{{.Body}}</div>
630 </article>
631 {{end}}
632 </section>
633 {{end}}
634 {{if or .CommitPrev .CommitNext}}
635 <nav class="clogmore">
636 {{if .CommitPrev}}<a href="{{.CommitPrev}}">{{t "commit.prev"}}</a>{{end}}
637 {{if .CommitNext}}<a href="{{.CommitNext}}">{{t "commit.more"}}</a>{{end}}
638 </nav>
639 {{end}}
640{{else if .Query}}
641<p class="muted">{{t "commit.none"}}</p>
642{{else}}
643<p class="muted">{{t "repo.noCommits"}}</p>
644{{end}}
645<script src="/assets/commits.js"></script>
646<script src="/assets/repo.js"></script>
582{{template "layout-end" .}}
647{{template "layout-end" .}}
583{{end}}
648{{end}}
584
649
internal/store/pipeline_retry.go added +177 −0
@@ -0,0 +1,177 @@
1 package store
2
3 import "context"
4
5 // ClonePipeline maakt een nieuwe pipeline op dezelfde commit, ref, bron
6 // en merge-requestkoppeling. De jobs beginnen opnieuw. Een geslaagde
7 // job van de oude pipeline blijft daar staan.
8 func (s *Store) ClonePipeline(ctx context.Context, repoID, id int64) (int64, error) {
9 p, err := s.PipelineByID(ctx, repoID, id)
10 if err != nil {
11 return 0, err
12 }
13 jobs, err := s.JobsByPipeline(ctx, id)
14 if err != nil {
15 return 0, err
16 }
17 tx, err := s.db.BeginTx(ctx, nil)
18 if err != nil {
19 return 0, err
20 }
21 defer func() { _ = tx.Rollback() }()
22 res, err := tx.ExecContext(ctx, `INSERT INTO pipelines (repo_id, commit_sha, ref, status, source, actor, commit_title, created_at, mr_id, target_sha)
23 VALUES (?, ?, ?, 'queued', ?, ?, ?, ?, ?, ?)`,
24 p.RepoID, p.CommitSHA, p.Ref, p.Source, p.Actor, p.CommitTitle, now(), p.MRID, p.TargetSHA)
25 if err != nil {
26 return 0, err
27 }
28 newID, _ := res.LastInsertId()
29 if err := insertPipelineJobs(ctx, tx, newID, p.RepoID, jobsToNew(jobs)); err != nil {
30 return 0, err
31 }
32 if err := tx.Commit(); err != nil {
33 return 0, err
34 }
35 return newID, nil
36 }
37
38 // RetryFailedJobs zet mislukte jobs terug in de wachtrij, plus de jobs
39 // die daardoor niets deden: overgeslagen of nooit gestarte jobs die via
40 // needs of een latere stage van een mislukte job afhangen.
41 // Geslaagde jobs blijven. false betekent dat er geen mislukte job is.
42 func (s *Store) RetryFailedJobs(ctx context.Context, pipelineID int64) (bool, error) {
43 jobs, err := s.JobsByPipeline(ctx, pipelineID)
44 if err != nil {
45 return false, err
46 }
47 plan := retryPlan(jobs)
48 if plan == nil {
49 return false, nil
50 }
51 tx, err := s.db.BeginTx(ctx, nil)
52 if err != nil {
53 return false, err
54 }
55 defer func() { _ = tx.Rollback() }()
56 for id, status := range plan {
57 if _, err := tx.ExecContext(ctx, `UPDATE jobs SET status = ?, log = '', attempt = 0, finished_at = NULL, started_at = NULL WHERE id = ? AND pipeline_id = ?`, status, id, pipelineID); err != nil {
58 return false, err
59 }
60 }
61 if err := tx.Commit(); err != nil {
62 return false, err
63 }
64 if _, err := s.RefreshPipelineStatus(ctx, pipelineID); err != nil {
65 return false, err
66 }
67 return true, nil
68 }
69
70 func jobsToNew(jobs []Job) []NewJob {
71 out := make([]NewJob, len(jobs))
72 for i, j := range jobs {
73 out[i] = NewJob{
74 Name: j.Name, Stage: j.Stage, Position: j.Position,
75 Image: j.Image, Before: j.Before, Script: j.Script, After: j.After,
76 Needs: j.Needs, Optional: j.Optional, NeedsSet: j.NeedsSet,
77 Variables: j.Variables, ArtifactPaths: j.ArtifactPaths, ArtifactExpire: j.ArtifactExpire,
78 AllowFailure: j.AllowFailure, When: j.When, Timeout: j.Timeout,
79 Tags: j.Tags, CachePaths: j.CachePaths, CacheKey: j.CacheKey,
80 ResourceGroup: j.ResourceGroup, RetryMax: j.RetryMax, RetryWhen: j.RetryWhen,
81 Services: j.Services, Environment: j.Environment, EnvironmentURL: j.EnvironmentURL,
82 Interruptible: j.Interruptible,
83 }
84 }
85 return out
86 }
87
88 // retryPlan kiest per job de nieuwe status.
89 // nil betekent dat geen enkele job de status failed heeft.
90 func retryPlan(jobs []Job) map[int64]string {
91 failed := map[int]bool{}
92 hasFailed := false
93 for i, j := range jobs {
94 if j.Status == "failed" {
95 failed[i] = true
96 hasFailed = true
97 }
98 }
99 if !hasFailed {
100 return nil
101 }
102 preds := predecessorIndexes(jobs)
103 down := map[int]bool{}
104 for {
105 moved := false
106 for i, j := range jobs {
107 if failed[i] || down[i] || !jobIdle(j.Status) {
108 continue
109 }
110 for _, p := range preds[i] {
111 if failed[p] || down[p] {
112 down[i] = true
113 moved = true
114 break
115 }
116 }
117 }
118 if !moved {
119 break
120 }
121 }
122 out := make(map[int64]string, len(failed)+len(down))
123 for i, j := range jobs {
124 switch {
125 case failed[i]:
126 out[j.ID] = "queued"
127 case down[i]:
128 if j.When == "manual" {
129 out[j.ID] = "manual"
130 } else {
131 out[j.ID] = "queued"
132 }
133 }
134 }
135 return out
136 }
137
138 // jobIdle is een job die nog niet gedraaid heeft of is overgeslagen.
139 func jobIdle(status string) bool {
140 switch status {
141 case "skipped", "created", "pending", "queued", "manual", "":
142 return true
143 default:
144 return false
145 }
146 }
147
148 // predecessorIndexes volgt needs als die gezet zijn, ook bij een lege lijst.
149 // Zonder needs zijn alle jobs in eerdere stages de voorgangers.
150 func predecessorIndexes(jobs []Job) [][]int {
151 byName := map[string][]int{}
152 stagePos := map[string]int{}
153 order := 0
154 for i, j := range jobs {
155 byName[j.Name] = append(byName[j.Name], i)
156 if _, ok := stagePos[j.Stage]; !ok {
157 stagePos[j.Stage] = order
158 order++
159 }
160 }
161 out := make([][]int, len(jobs))
162 for i, j := range jobs {
163 if j.NeedsSet {
164 for _, n := range j.Needs {
165 out[i] = append(out[i], byName[n]...)
166 }
167 continue
168 }
169 my := stagePos[j.Stage]
170 for k, other := range jobs {
171 if k != i && stagePos[other.Stage] < my {
172 out[i] = append(out[i], k)
173 }
174 }
175 }
176 return out
177 }
@@ -0,0 +1,177 @@
1package store
2
3import "context"
4
5// ClonePipeline maakt een nieuwe pipeline op dezelfde commit, ref, bron
6// en merge-requestkoppeling. De jobs beginnen opnieuw. Een geslaagde
7// job van de oude pipeline blijft daar staan.
8func (s *Store) ClonePipeline(ctx context.Context, repoID, id int64) (int64, error) {
9 p, err := s.PipelineByID(ctx, repoID, id)
10 if err != nil {
11 return 0, err
12 }
13 jobs, err := s.JobsByPipeline(ctx, id)
14 if err != nil {
15 return 0, err
16 }
17 tx, err := s.db.BeginTx(ctx, nil)
18 if err != nil {
19 return 0, err
20 }
21 defer func() { _ = tx.Rollback() }()
22 res, err := tx.ExecContext(ctx, `INSERT INTO pipelines (repo_id, commit_sha, ref, status, source, actor, commit_title, created_at, mr_id, target_sha)
23 VALUES (?, ?, ?, 'queued', ?, ?, ?, ?, ?, ?)`,
24 p.RepoID, p.CommitSHA, p.Ref, p.Source, p.Actor, p.CommitTitle, now(), p.MRID, p.TargetSHA)
25 if err != nil {
26 return 0, err
27 }
28 newID, _ := res.LastInsertId()
29 if err := insertPipelineJobs(ctx, tx, newID, p.RepoID, jobsToNew(jobs)); err != nil {
30 return 0, err
31 }
32 if err := tx.Commit(); err != nil {
33 return 0, err
34 }
35 return newID, nil
36}
37
38// RetryFailedJobs zet mislukte jobs terug in de wachtrij, plus de jobs
39// die daardoor niets deden: overgeslagen of nooit gestarte jobs die via
40// needs of een latere stage van een mislukte job afhangen.
41// Geslaagde jobs blijven. false betekent dat er geen mislukte job is.
42func (s *Store) RetryFailedJobs(ctx context.Context, pipelineID int64) (bool, error) {
43 jobs, err := s.JobsByPipeline(ctx, pipelineID)
44 if err != nil {
45 return false, err
46 }
47 plan := retryPlan(jobs)
48 if plan == nil {
49 return false, nil
50 }
51 tx, err := s.db.BeginTx(ctx, nil)
52 if err != nil {
53 return false, err
54 }
55 defer func() { _ = tx.Rollback() }()
56 for id, status := range plan {
57 if _, err := tx.ExecContext(ctx, `UPDATE jobs SET status = ?, log = '', attempt = 0, finished_at = NULL, started_at = NULL WHERE id = ? AND pipeline_id = ?`, status, id, pipelineID); err != nil {
58 return false, err
59 }
60 }
61 if err := tx.Commit(); err != nil {
62 return false, err
63 }
64 if _, err := s.RefreshPipelineStatus(ctx, pipelineID); err != nil {
65 return false, err
66 }
67 return true, nil
68}
69
70func jobsToNew(jobs []Job) []NewJob {
71 out := make([]NewJob, len(jobs))
72 for i, j := range jobs {
73 out[i] = NewJob{
74 Name: j.Name, Stage: j.Stage, Position: j.Position,
75 Image: j.Image, Before: j.Before, Script: j.Script, After: j.After,
76 Needs: j.Needs, Optional: j.Optional, NeedsSet: j.NeedsSet,
77 Variables: j.Variables, ArtifactPaths: j.ArtifactPaths, ArtifactExpire: j.ArtifactExpire,
78 AllowFailure: j.AllowFailure, When: j.When, Timeout: j.Timeout,
79 Tags: j.Tags, CachePaths: j.CachePaths, CacheKey: j.CacheKey,
80 ResourceGroup: j.ResourceGroup, RetryMax: j.RetryMax, RetryWhen: j.RetryWhen,
81 Services: j.Services, Environment: j.Environment, EnvironmentURL: j.EnvironmentURL,
82 Interruptible: j.Interruptible,
83 }
84 }
85 return out
86}
87
88// retryPlan kiest per job de nieuwe status.
89// nil betekent dat geen enkele job de status failed heeft.
90func retryPlan(jobs []Job) map[int64]string {
91 failed := map[int]bool{}
92 hasFailed := false
93 for i, j := range jobs {
94 if j.Status == "failed" {
95 failed[i] = true
96 hasFailed = true
97 }
98 }
99 if !hasFailed {
100 return nil
101 }
102 preds := predecessorIndexes(jobs)
103 down := map[int]bool{}
104 for {
105 moved := false
106 for i, j := range jobs {
107 if failed[i] || down[i] || !jobIdle(j.Status) {
108 continue
109 }
110 for _, p := range preds[i] {
111 if failed[p] || down[p] {
112 down[i] = true
113 moved = true
114 break
115 }
116 }
117 }
118 if !moved {
119 break
120 }
121 }
122 out := make(map[int64]string, len(failed)+len(down))
123 for i, j := range jobs {
124 switch {
125 case failed[i]:
126 out[j.ID] = "queued"
127 case down[i]:
128 if j.When == "manual" {
129 out[j.ID] = "manual"
130 } else {
131 out[j.ID] = "queued"
132 }
133 }
134 }
135 return out
136}
137
138// jobIdle is een job die nog niet gedraaid heeft of is overgeslagen.
139func jobIdle(status string) bool {
140 switch status {
141 case "skipped", "created", "pending", "queued", "manual", "":
142 return true
143 default:
144 return false
145 }
146}
147
148// predecessorIndexes volgt needs als die gezet zijn, ook bij een lege lijst.
149// Zonder needs zijn alle jobs in eerdere stages de voorgangers.
150func predecessorIndexes(jobs []Job) [][]int {
151 byName := map[string][]int{}
152 stagePos := map[string]int{}
153 order := 0
154 for i, j := range jobs {
155 byName[j.Name] = append(byName[j.Name], i)
156 if _, ok := stagePos[j.Stage]; !ok {
157 stagePos[j.Stage] = order
158 order++
159 }
160 }
161 out := make([][]int, len(jobs))
162 for i, j := range jobs {
163 if j.NeedsSet {
164 for _, n := range j.Needs {
165 out[i] = append(out[i], byName[n]...)
166 }
167 continue
168 }
169 my := stagePos[j.Stage]
170 for k, other := range jobs {
171 if k != i && stagePos[other.Stage] < my {
172 out[i] = append(out[i], k)
173 }
174 }
175 }
176 return out
177}
internal/store/pipeline_retry_test.go added +141 −0
@@ -0,0 +1,141 @@
1 package store
2
3 import (
4 "context"
5 "testing"
6 )
7
8 func TestRetryPlanFollowsNeedsAndLaterStages(t *testing.T) {
9 jobs := []Job{
10 {ID: 1, Name: "lint", Stage: "test", Status: "success"},
11 {ID: 2, Name: "unit", Stage: "test", Status: "failed"},
12 {ID: 3, Name: "soft", Stage: "test", Status: "failed", AllowFailure: true},
13 {ID: 4, Name: "side", Stage: "test", Status: "skipped"},
14 {ID: 5, Name: "pack", Stage: "package", Status: "skipped"},
15 {ID: 6, Name: "aur", Stage: "package", Status: "success", NeedsSet: true},
16 {ID: 7, Name: "release", Stage: "package", Status: "skipped", Needs: []string{"pack"}, NeedsSet: true},
17 {ID: 8, Name: "pages", Stage: "package", Status: "skipped", When: "manual"},
18 {ID: 9, Name: "note", Stage: "package", Status: "canceled"},
19 {ID: 10, Name: "hold", Stage: "package", Status: "created"},
20 {ID: 11, Name: "wait", Stage: "package", Status: "pending"},
21 {ID: 12, Name: "run", Stage: "package", Status: "running"},
22 }
23 plan := retryPlan(jobs)
24 want := map[int64]string{
25 2: "queued", 3: "queued", 5: "queued", 7: "queued",
26 8: "manual", 10: "queued", 11: "queued",
27 }
28 if len(plan) != len(want) {
29 t.Fatalf("plan %v, wil %v", plan, want)
30 }
31 for id, status := range want {
32 if plan[id] != status {
33 t.Fatalf("job %d is %q, wil %q in %v", id, plan[id], status, plan)
34 }
35 }
36 if retryPlan([]Job{{ID: 1, Name: "lint", Status: "success"}, {ID: 2, Name: "pack", Status: "skipped"}}) != nil {
37 t.Fatal("zonder mislukte job is er niets om opnieuw te draaien")
38 }
39 }
40
41 func TestCloneAndRetryFailedJobs(t *testing.T) {
42 s := openTest(t)
43 ctx := context.Background()
44 tim, err := s.UpsertUser(ctx, 1, "tim", "", false)
45 if err != nil {
46 t.Fatal(err)
47 }
48 repo, err := s.CreateRepo(ctx, "user", tim.ID, "ci", "", "master", "private")
49 if err != nil {
50 t.Fatal(err)
51 }
52 sha := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
53 ref := "refs/heads/topic"
54 target := "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
55 id, err := s.CreatePipeline(ctx, repo.ID, sha, ref, "merge_request_event", "tim", "titel", []NewJob{
56 {Name: "lint", Stage: "test", Position: 0, Script: "exit 0"},
57 {Name: "unit", Stage: "test", Position: 1, Script: "exit 1"},
58 {Name: "pack", Stage: "deploy", Position: 2, Script: "exit 0"},
59 {Name: "pages", Stage: "deploy", Position: 3, Script: "exit 0", When: "manual"},
60 {Name: "aur", Stage: "deploy", Position: 4, Script: "echo aur", NeedsSet: true},
61 })
62 if err != nil {
63 t.Fatal(err)
64 }
65 if _, err := s.db.ExecContext(ctx, `UPDATE pipelines SET mr_id = ?, target_sha = ? WHERE id = ?`, 9, target, id); err != nil {
66 t.Fatal(err)
67 }
68 set := func(name, status string) {
69 t.Helper()
70 if _, err := s.db.ExecContext(ctx, `UPDATE jobs SET status = ? WHERE pipeline_id = ? AND name = ?`, status, id, name); err != nil {
71 t.Fatal(err)
72 }
73 }
74 set("lint", "success")
75 set("unit", "failed")
76 set("pack", "skipped")
77 set("pages", "skipped")
78 set("aur", "success")
79 if _, err := s.RefreshPipelineStatus(ctx, id); err != nil {
80 t.Fatal(err)
81 }
82
83 ok, err := s.RetryFailedJobs(ctx, id)
84 if err != nil || !ok {
85 t.Fatalf("retry: %v %v", ok, err)
86 }
87 got := jobStatus(t, s, id)
88 if got["lint"] != "success" || got["aur"] != "success" {
89 t.Fatalf("geslaagd hoort te blijven: %v", got)
90 }
91 if got["unit"] != "queued" || got["pack"] != "queued" || got["pages"] != "manual" {
92 t.Fatalf("opnieuw: %v", got)
93 }
94 p, err := s.PipelineByID(ctx, repo.ID, id)
95 if err != nil || p.Status != "running" {
96 t.Fatalf("status na retry: %+v %v", p, err)
97 }
98 again, err := s.RetryFailedJobs(ctx, id)
99 if err != nil || again {
100 t.Fatalf("tweede keer zonder mislukking: %v %v", again, err)
101 }
102
103 newID, err := s.ClonePipeline(ctx, repo.ID, id)
104 if err != nil || newID == id {
105 t.Fatalf("kloon %d %v", newID, err)
106 }
107 clone, err := s.PipelineByID(ctx, repo.ID, newID)
108 if err != nil {
109 t.Fatal(err)
110 }
111 if clone.CommitSHA != sha || clone.Ref != ref || clone.Source != "merge_request_event" || clone.Actor != "tim" || clone.CommitTitle != "titel" || clone.MRID != 9 || clone.TargetSHA != target || clone.Status != "queued" {
112 t.Fatalf("kloon wijkt af: %+v", clone)
113 }
114 cloned := jobStatus(t, s, newID)
115 if cloned["lint"] != "queued" || cloned["unit"] != "queued" || cloned["pack"] != "queued" || cloned["aur"] != "queued" || cloned["pages"] != "manual" {
116 t.Fatalf("nieuwe jobs: %v", cloned)
117 }
118 kept := jobStatus(t, s, id)
119 if kept["lint"] != "success" || kept["unit"] != "queued" {
120 t.Fatalf("oude pipeline veranderde: %v", kept)
121 }
122 againID, created, err := s.OpenPipeline(ctx, repo.ID, sha, ref, "merge_request_event", "tim", "titel", target, 9, []NewJob{
123 {Name: "lint", Stage: "test", Script: "exit 0"},
124 })
125 if err != nil || created || againID != id {
126 t.Fatalf("dedupe hoort de oudste rij te houden: %d created=%v %v", againID, created, err)
127 }
128 }
129
130 func jobStatus(t *testing.T, s *Store, id int64) map[string]string {
131 t.Helper()
132 jobs, err := s.JobsByPipeline(context.Background(), id)
133 if err != nil {
134 t.Fatal(err)
135 }
136 out := map[string]string{}
137 for _, j := range jobs {
138 out[j.Name] = j.Status
139 }
140 return out
141 }
@@ -0,0 +1,141 @@
1package store
2
3import (
4 "context"
5 "testing"
6)
7
8func TestRetryPlanFollowsNeedsAndLaterStages(t *testing.T) {
9 jobs := []Job{
10 {ID: 1, Name: "lint", Stage: "test", Status: "success"},
11 {ID: 2, Name: "unit", Stage: "test", Status: "failed"},
12 {ID: 3, Name: "soft", Stage: "test", Status: "failed", AllowFailure: true},
13 {ID: 4, Name: "side", Stage: "test", Status: "skipped"},
14 {ID: 5, Name: "pack", Stage: "package", Status: "skipped"},
15 {ID: 6, Name: "aur", Stage: "package", Status: "success", NeedsSet: true},
16 {ID: 7, Name: "release", Stage: "package", Status: "skipped", Needs: []string{"pack"}, NeedsSet: true},
17 {ID: 8, Name: "pages", Stage: "package", Status: "skipped", When: "manual"},
18 {ID: 9, Name: "note", Stage: "package", Status: "canceled"},
19 {ID: 10, Name: "hold", Stage: "package", Status: "created"},
20 {ID: 11, Name: "wait", Stage: "package", Status: "pending"},
21 {ID: 12, Name: "run", Stage: "package", Status: "running"},
22 }
23 plan := retryPlan(jobs)
24 want := map[int64]string{
25 2: "queued", 3: "queued", 5: "queued", 7: "queued",
26 8: "manual", 10: "queued", 11: "queued",
27 }
28 if len(plan) != len(want) {
29 t.Fatalf("plan %v, wil %v", plan, want)
30 }
31 for id, status := range want {
32 if plan[id] != status {
33 t.Fatalf("job %d is %q, wil %q in %v", id, plan[id], status, plan)
34 }
35 }
36 if retryPlan([]Job{{ID: 1, Name: "lint", Status: "success"}, {ID: 2, Name: "pack", Status: "skipped"}}) != nil {
37 t.Fatal("zonder mislukte job is er niets om opnieuw te draaien")
38 }
39}
40
41func TestCloneAndRetryFailedJobs(t *testing.T) {
42 s := openTest(t)
43 ctx := context.Background()
44 tim, err := s.UpsertUser(ctx, 1, "tim", "", false)
45 if err != nil {
46 t.Fatal(err)
47 }
48 repo, err := s.CreateRepo(ctx, "user", tim.ID, "ci", "", "master", "private")
49 if err != nil {
50 t.Fatal(err)
51 }
52 sha := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
53 ref := "refs/heads/topic"
54 target := "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
55 id, err := s.CreatePipeline(ctx, repo.ID, sha, ref, "merge_request_event", "tim", "titel", []NewJob{
56 {Name: "lint", Stage: "test", Position: 0, Script: "exit 0"},
57 {Name: "unit", Stage: "test", Position: 1, Script: "exit 1"},
58 {Name: "pack", Stage: "deploy", Position: 2, Script: "exit 0"},
59 {Name: "pages", Stage: "deploy", Position: 3, Script: "exit 0", When: "manual"},
60 {Name: "aur", Stage: "deploy", Position: 4, Script: "echo aur", NeedsSet: true},
61 })
62 if err != nil {
63 t.Fatal(err)
64 }
65 if _, err := s.db.ExecContext(ctx, `UPDATE pipelines SET mr_id = ?, target_sha = ? WHERE id = ?`, 9, target, id); err != nil {
66 t.Fatal(err)
67 }
68 set := func(name, status string) {
69 t.Helper()
70 if _, err := s.db.ExecContext(ctx, `UPDATE jobs SET status = ? WHERE pipeline_id = ? AND name = ?`, status, id, name); err != nil {
71 t.Fatal(err)
72 }
73 }
74 set("lint", "success")
75 set("unit", "failed")
76 set("pack", "skipped")
77 set("pages", "skipped")
78 set("aur", "success")
79 if _, err := s.RefreshPipelineStatus(ctx, id); err != nil {
80 t.Fatal(err)
81 }
82
83 ok, err := s.RetryFailedJobs(ctx, id)
84 if err != nil || !ok {
85 t.Fatalf("retry: %v %v", ok, err)
86 }
87 got := jobStatus(t, s, id)
88 if got["lint"] != "success" || got["aur"] != "success" {
89 t.Fatalf("geslaagd hoort te blijven: %v", got)
90 }
91 if got["unit"] != "queued" || got["pack"] != "queued" || got["pages"] != "manual" {
92 t.Fatalf("opnieuw: %v", got)
93 }
94 p, err := s.PipelineByID(ctx, repo.ID, id)
95 if err != nil || p.Status != "running" {
96 t.Fatalf("status na retry: %+v %v", p, err)
97 }
98 again, err := s.RetryFailedJobs(ctx, id)
99 if err != nil || again {
100 t.Fatalf("tweede keer zonder mislukking: %v %v", again, err)
101 }
102
103 newID, err := s.ClonePipeline(ctx, repo.ID, id)
104 if err != nil || newID == id {
105 t.Fatalf("kloon %d %v", newID, err)
106 }
107 clone, err := s.PipelineByID(ctx, repo.ID, newID)
108 if err != nil {
109 t.Fatal(err)
110 }
111 if clone.CommitSHA != sha || clone.Ref != ref || clone.Source != "merge_request_event" || clone.Actor != "tim" || clone.CommitTitle != "titel" || clone.MRID != 9 || clone.TargetSHA != target || clone.Status != "queued" {
112 t.Fatalf("kloon wijkt af: %+v", clone)
113 }
114 cloned := jobStatus(t, s, newID)
115 if cloned["lint"] != "queued" || cloned["unit"] != "queued" || cloned["pack"] != "queued" || cloned["aur"] != "queued" || cloned["pages"] != "manual" {
116 t.Fatalf("nieuwe jobs: %v", cloned)
117 }
118 kept := jobStatus(t, s, id)
119 if kept["lint"] != "success" || kept["unit"] != "queued" {
120 t.Fatalf("oude pipeline veranderde: %v", kept)
121 }
122 againID, created, err := s.OpenPipeline(ctx, repo.ID, sha, ref, "merge_request_event", "tim", "titel", target, 9, []NewJob{
123 {Name: "lint", Stage: "test", Script: "exit 0"},
124 })
125 if err != nil || created || againID != id {
126 t.Fatalf("dedupe hoort de oudste rij te houden: %d created=%v %v", againID, created, err)
127 }
128}
129
130func jobStatus(t *testing.T, s *Store, id int64) map[string]string {
131 t.Helper()
132 jobs, err := s.JobsByPipeline(context.Background(), id)
133 if err != nil {
134 t.Fatal(err)
135 }
136 out := map[string]string{}
137 for _, j := range jobs {
138 out[j.Name] = j.Status
139 }
140 return out
141}
internal/store/repos.go +24 −7
@@ -29,6 +29,14 @@ type Group struct {
29 29 // HasLogo meldt of er een geüpload logo is.
30 30 func (g Group) HasLogo() bool { return g.LogoMIME != "" }
31 31
32 // LogoURL is het pad van het groepslogo, of leeg.
33 func (g Group) LogoURL() string {
34 if !g.HasLogo() {
35 return ""
36 }
37 return "/groups/" + g.Path + "/logo"
38 }
39
32 40 // Repo is een git-repository van een gebruiker of een groep.
33 41 type Repo struct {
34 42 ID int64
@@ -46,6 +54,14 @@ type Repo struct {
46 54 // HasLogo meldt of er een geüpload logo is.
47 55 func (r Repo) HasLogo() bool { return r.LogoMIME != "" }
48 56
57 // LogoURL is het pad van het repologo, of leeg.
58 func (r Repo) LogoURL() string {
59 if !r.HasLogo() {
60 return ""
61 }
62 return "/" + r.FullPath() + "/-/logo"
63 }
64
49 65 // FullPath is owner/naam.
50 66 func (r Repo) FullPath() string { return r.OwnerPath + "/" + r.Name }
51 67
@@ -409,10 +425,11 @@ func (s *Store) EffectiveRole(ctx context.Context, userID, repoID int64) (access
409 425
410 426 // Member is een lid of een uitnodiging op gebruikersnaam.
411 427 type Member struct {
412 UserID int64
413 Username string
414 Role access.Role
415 Pending bool
428 UserID int64
429 Username string
430 AvatarURL string
431 Role access.Role
432 Pending bool
416 433 }
417 434
418 435 // SetMember zet een lidmaatschap. Een onbekende naam blijft wachten tot de eerste login.
@@ -488,9 +505,9 @@ func (s *Store) RemoveMember(ctx context.Context, scopeKind string, scopeID int6
488 505 func (s *Store) ListMembers(ctx context.Context, scopeKind string, scopeID int64) ([]Member, error) {
489 506 var q string
490 507 if scopeKind == "group" {
491 q = `SELECT u.id, u.username, m.role FROM group_members m JOIN users u ON u.id = m.user_id WHERE m.group_id = ? ORDER BY u.username`
508 q = `SELECT u.id, u.username, u.avatar_url, m.role FROM group_members m JOIN users u ON u.id = m.user_id WHERE m.group_id = ? ORDER BY u.username`
492 509 } else {
493 q = `SELECT u.id, u.username, m.role FROM repo_members m JOIN users u ON u.id = m.user_id WHERE m.repo_id = ? ORDER BY u.username`
510 q = `SELECT u.id, u.username, u.avatar_url, m.role FROM repo_members m JOIN users u ON u.id = m.user_id WHERE m.repo_id = ? ORDER BY u.username`
494 511 }
495 512 rows, err := s.db.QueryContext(ctx, q, scopeID)
496 513 if err != nil {
@@ -501,7 +518,7 @@ func (s *Store) ListMembers(ctx context.Context, scopeKind string, scopeID int64
501 518 for rows.Next() {
502 519 var m Member
503 520 var role string
504 if err := rows.Scan(&m.UserID, &m.Username, &role); err != nil {
521 if err := rows.Scan(&m.UserID, &m.Username, &m.AvatarURL, &role); err != nil {
505 522 return nil, err
506 523 }
507 524 m.Role = access.Role(role)
@@ -29,6 +29,14 @@ type Group struct {
29// HasLogo meldt of er een geüpload logo is.
29// HasLogo meldt of er een geüpload logo is.
30func (g Group) HasLogo() bool { return g.LogoMIME != "" }
30func (g Group) HasLogo() bool { return g.LogoMIME != "" }
31
31
32// LogoURL is het pad van het groepslogo, of leeg.
33func (g Group) LogoURL() string {
34 if !g.HasLogo() {
35 return ""
36 }
37 return "/groups/" + g.Path + "/logo"
38}
39
32// Repo is een git-repository van een gebruiker of een groep.
40// Repo is een git-repository van een gebruiker of een groep.
33type Repo struct {
41type Repo struct {
34 ID int64
42 ID int64
@@ -46,6 +54,14 @@ type Repo struct {
46// HasLogo meldt of er een geüpload logo is.
54// HasLogo meldt of er een geüpload logo is.
47func (r Repo) HasLogo() bool { return r.LogoMIME != "" }
55func (r Repo) HasLogo() bool { return r.LogoMIME != "" }
48
56
57// LogoURL is het pad van het repologo, of leeg.
58func (r Repo) LogoURL() string {
59 if !r.HasLogo() {
60 return ""
61 }
62 return "/" + r.FullPath() + "/-/logo"
63}
64
49// FullPath is owner/naam.
65// FullPath is owner/naam.
50func (r Repo) FullPath() string { return r.OwnerPath + "/" + r.Name }
66func (r Repo) FullPath() string { return r.OwnerPath + "/" + r.Name }
51
67
@@ -409,10 +425,11 @@ func (s *Store) EffectiveRole(ctx context.Context, userID, repoID int64) (access
409
425
410// Member is een lid of een uitnodiging op gebruikersnaam.
426// Member is een lid of een uitnodiging op gebruikersnaam.
411type Member struct {
427type Member struct {
412 UserID int64
428 UserID int64
413 Username string
429 Username string
414 Role access.Role
430 AvatarURL string
415 Pending bool
431 Role access.Role
432 Pending bool
416}
433}
417
434
418// SetMember zet een lidmaatschap. Een onbekende naam blijft wachten tot de eerste login.
435// SetMember zet een lidmaatschap. Een onbekende naam blijft wachten tot de eerste login.
@@ -488,9 +505,9 @@ func (s *Store) RemoveMember(ctx context.Context, scopeKind string, scopeID int6
488func (s *Store) ListMembers(ctx context.Context, scopeKind string, scopeID int64) ([]Member, error) {
505func (s *Store) ListMembers(ctx context.Context, scopeKind string, scopeID int64) ([]Member, error) {
489 var q string
506 var q string
490 if scopeKind == "group" {
507 if scopeKind == "group" {
491 q = `SELECT u.id, u.username, m.role FROM group_members m JOIN users u ON u.id = m.user_id WHERE m.group_id = ? ORDER BY u.username`
508 q = `SELECT u.id, u.username, u.avatar_url, m.role FROM group_members m JOIN users u ON u.id = m.user_id WHERE m.group_id = ? ORDER BY u.username`
492 } else {
509 } else {
493 q = `SELECT u.id, u.username, m.role FROM repo_members m JOIN users u ON u.id = m.user_id WHERE m.repo_id = ? ORDER BY u.username`
510 q = `SELECT u.id, u.username, u.avatar_url, m.role FROM repo_members m JOIN users u ON u.id = m.user_id WHERE m.repo_id = ? ORDER BY u.username`
494 }
511 }
495 rows, err := s.db.QueryContext(ctx, q, scopeID)
512 rows, err := s.db.QueryContext(ctx, q, scopeID)
496 if err != nil {
513 if err != nil {
@@ -501,7 +518,7 @@ func (s *Store) ListMembers(ctx context.Context, scopeKind string, scopeID int64
501 for rows.Next() {
518 for rows.Next() {
502 var m Member
519 var m Member
503 var role string
520 var role string
504 if err := rows.Scan(&m.UserID, &m.Username, &role); err != nil {
521 if err := rows.Scan(&m.UserID, &m.Username, &m.AvatarURL, &role); err != nil {
505 return nil, err
522 return nil, err
506 }
523 }
507 m.Role = access.Role(role)
524 m.Role = access.Role(role)
packaging/aur/.SRCINFO +3 −3
@@ -2,7 +2,7 @@ pkgbase = bluegit
2 2 pkgdesc = Self-hosted git-platform
3 3 pkgver = 20261022020626
4 4 pkgrel = 1
5 url = https://gitlab.com/Timfa/bluegit
5 url = https://git.timfalken.com/timfa/bluegit
6 6 install = bluegit.install
7 7 arch = x86_64
8 8 license = MIT
@@ -11,7 +11,7 @@ pkgbase = bluegit
11 11 makedepends = go
12 12 backup = etc/bluegit/config.yml
13 13 options = !debug
14 source = bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/e65fc3c65c4e830955b015eba9b971335b6ceed8/bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz
15 sha256sums = 5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b02
14 source = bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz::https://git.timfalken.com/timfa/bluegit/-/archive/e65fc3c65c4e830955b015eba9b971335b6ceed8/bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz
15 sha256sums = f40837ad2c6bf3cdea6080b3d257af44d2fcdb78659e59468c8fea5c33b7f338
16 16
17 17 pkgname = bluegit
@@ -2,7 +2,7 @@ pkgbase = bluegit
2 pkgdesc = Self-hosted git-platform
2 pkgdesc = Self-hosted git-platform
3 pkgver = 20261022020626
3 pkgver = 20261022020626
4 pkgrel = 1
4 pkgrel = 1
5 url = https://gitlab.com/Timfa/bluegit
5 url = https://git.timfalken.com/timfa/bluegit
6 install = bluegit.install
6 install = bluegit.install
7 arch = x86_64
7 arch = x86_64
8 license = MIT
8 license = MIT
@@ -11,7 +11,7 @@ pkgbase = bluegit
11 makedepends = go
11 makedepends = go
12 backup = etc/bluegit/config.yml
12 backup = etc/bluegit/config.yml
13 options = !debug
13 options = !debug
14 source = bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/e65fc3c65c4e830955b015eba9b971335b6ceed8/bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz
14 source = bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz::https://git.timfalken.com/timfa/bluegit/-/archive/e65fc3c65c4e830955b015eba9b971335b6ceed8/bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz
15 sha256sums = 5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b02
15 sha256sums = f40837ad2c6bf3cdea6080b3d257af44d2fcdb78659e59468c8fea5c33b7f338
16
16
17pkgname = bluegit
17pkgname = bluegit
packaging/aur/PKGBUILD +3 −3
@@ -4,7 +4,7 @@ pkgver=20261022020626
4 4 pkgrel=1
5 5 pkgdesc='Self-hosted git-platform'
6 6 arch=('x86_64')
7 url='https://gitlab.com/Timfa/bluegit'
7 url='https://git.timfalken.com/timfa/bluegit'
8 8 license=('MIT')
9 9 depends=('git' 'docker')
10 10 makedepends=('go')
@@ -12,8 +12,8 @@ backup=('etc/bluegit/config.yml')
12 12 options=('!debug')
13 13 install=bluegit.install
14 14 _commit=e65fc3c65c4e830955b015eba9b971335b6ceed8
15 source=("bluegit-${_commit}.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz")
16 sha256sums=('5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b02')
15 source=("bluegit-${_commit}.tar.gz::https://git.timfalken.com/timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz")
16 sha256sums=('f40837ad2c6bf3cdea6080b3d257af44d2fcdb78659e59468c8fea5c33b7f338')
17 17
18 18 build() {
19 19 cd "$srcdir/bluegit-${_commit}"
@@ -4,7 +4,7 @@ pkgver=20261022020626
4pkgrel=1
4pkgrel=1
5pkgdesc='Self-hosted git-platform'
5pkgdesc='Self-hosted git-platform'
6arch=('x86_64')
6arch=('x86_64')
7url='https://gitlab.com/Timfa/bluegit'
7url='https://git.timfalken.com/timfa/bluegit'
8license=('MIT')
8license=('MIT')
9depends=('git' 'docker')
9depends=('git' 'docker')
10makedepends=('go')
10makedepends=('go')
@@ -12,8 +12,8 @@ backup=('etc/bluegit/config.yml')
12options=('!debug')
12options=('!debug')
13install=bluegit.install
13install=bluegit.install
14_commit=e65fc3c65c4e830955b015eba9b971335b6ceed8
14_commit=e65fc3c65c4e830955b015eba9b971335b6ceed8
15source=("bluegit-${_commit}.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz")
15source=("bluegit-${_commit}.tar.gz::https://git.timfalken.com/timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz")
16sha256sums=('5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b02')
16sha256sums=('f40837ad2c6bf3cdea6080b3d257af44d2fcdb78659e59468c8fea5c33b7f338')
17
17
18build() {
18build() {
19 cd "$srcdir/bluegit-${_commit}"
19 cd "$srcdir/bluegit-${_commit}"
scripts/aur_test.go +1 −1
@@ -47,7 +47,7 @@ func TestRewritePkgbuild(t *testing.T) {
47 47 "pkgrel=1",
48 48 "_commit=" + commit,
49 49 "sha256sums=('" + sum + "')",
50 "https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz",
50 "https://git.timfalken.com/timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz",
51 51 } {
52 52 if !strings.Contains(text, want) {
53 53 t.Fatalf("mist %q in\n%s", want, text)
@@ -47,7 +47,7 @@ func TestRewritePkgbuild(t *testing.T) {
47 "pkgrel=1",
47 "pkgrel=1",
48 "_commit=" + commit,
48 "_commit=" + commit,
49 "sha256sums=('" + sum + "')",
49 "sha256sums=('" + sum + "')",
50 "https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz",
50 "https://git.timfalken.com/timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz",
51 } {
51 } {
52 if !strings.Contains(text, want) {
52 if !strings.Contains(text, want) {
53 t.Fatalf("mist %q in\n%s", want, text)
53 t.Fatalf("mist %q in\n%s", want, text)
scripts/publish-aur.sh +2 −2
@@ -1,5 +1,5 @@
1 1 #!/usr/bin/env bash
2 # Update the AUR package bluegit from the GitLab source archive of this commit.
2 # Update the AUR package bluegit from the BlueGit source archive of this commit.
3 3 # Pushes ssh://aur@aur.archlinux.org/bluegit.git master. AUR only accepts master.
4 4 set -euo pipefail
5 5
@@ -93,7 +93,7 @@ WORKDIR="$(mktemp -d "$TMPDIR/bluegit-aur-XXXXXX")"
93 93 cleanup() { rm -rf "$WORKDIR"; }
94 94 trap cleanup EXIT
95 95
96 SOURCE_URL="https://gitlab.com/Timfa/bluegit/-/archive/${COMMIT}/bluegit-${COMMIT}.tar.gz"
96 SOURCE_URL="https://git.timfalken.com/timfa/bluegit/-/archive/${COMMIT}/bluegit-${COMMIT}.tar.gz"
97 97 TMP_SOURCE="$WORKDIR/source.tar.gz"
98 98 echo "Checking source tarball: $SOURCE_URL"
99 99 if ! curl -fsSL "$SOURCE_URL" -o "$TMP_SOURCE"; then
@@ -1,5 +1,5 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2# Update the AUR package bluegit from the GitLab source archive of this commit.
2# Update the AUR package bluegit from the BlueGit source archive of this commit.
3# Pushes ssh://aur@aur.archlinux.org/bluegit.git master. AUR only accepts master.
3# Pushes ssh://aur@aur.archlinux.org/bluegit.git master. AUR only accepts master.
4set -euo pipefail
4set -euo pipefail
5
5
@@ -93,7 +93,7 @@ WORKDIR="$(mktemp -d "$TMPDIR/bluegit-aur-XXXXXX")"
93cleanup() { rm -rf "$WORKDIR"; }
93cleanup() { rm -rf "$WORKDIR"; }
94trap cleanup EXIT
94trap cleanup EXIT
95
95
96SOURCE_URL="https://gitlab.com/Timfa/bluegit/-/archive/${COMMIT}/bluegit-${COMMIT}.tar.gz"
96SOURCE_URL="https://git.timfalken.com/timfa/bluegit/-/archive/${COMMIT}/bluegit-${COMMIT}.tar.gz"
97TMP_SOURCE="$WORKDIR/source.tar.gz"
97TMP_SOURCE="$WORKDIR/source.tar.gz"
98echo "Checking source tarball: $SOURCE_URL"
98echo "Checking source tarball: $SOURCE_URL"
99if ! curl -fsSL "$SOURCE_URL" -o "$TMP_SOURCE"; then
99if ! curl -fsSL "$SOURCE_URL" -o "$TMP_SOURCE"; then