BlueGit

timfa bluegit

Files

bluegit / internal / server / server.go

server.go

feat: voeg image-presets en een CI-infopagina toe
timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa · 3 weeks ago
a6677fb6 History
server.go 19.0 KiB Download Raw
1// Package server is de webinterface, de git-HTTP-server en de API.
2package server
3
4import (
5 "context"
6 "crypto/rand"
7 "embed"
8 "encoding/hex"
9 "html/template"
10 "io/fs"
11 "log/slog"
12 "net/http"
13 "net/url"
14 "strings"
15 "sync"
16 "time"
17 "unicode/utf8"
18
19 "gitlab.com/Timfa/bluegit/internal/access"
20 "gitlab.com/Timfa/bluegit/internal/activity"
21 "gitlab.com/Timfa/bluegit/internal/auth"
22 "gitlab.com/Timfa/bluegit/internal/cispec"
23 "gitlab.com/Timfa/bluegit/internal/config"
24 "gitlab.com/Timfa/bluegit/internal/i18n"
25 "gitlab.com/Timfa/bluegit/internal/realip"
26 "gitlab.com/Timfa/bluegit/internal/runner"
27 "gitlab.com/Timfa/bluegit/internal/store"
28)
29
30//go:embed templates/*.html static/*
31var webFS embed.FS
32
33// Server bedient BlueGit.
34type Server struct {
35 Cfg config.Config
36 Store *store.Store
37 Auth auth.Provider
38 Mail auth.Mailer
39 Dev bool
40 Git string
41 HookBin string
42 Runner *runner.Runner
43 Log *slog.Logger
44 // StateDir is de map met database en het bestand storage_path.
45 StateDir string
46 // AfterStorage krijgt het nieuwe datadisk-pad, voor runner en SSH.
47 AfterStorage func(path string)
48 tmpl *template.Template
49 byLang map[string]*template.Template
50
51 storageMu sync.RWMutex
52 storage string
53 storageSet bool
54}
55
56type principal struct {
57 User store.User
58 Session store.Session
59 OK bool
60}
61
62type ctxKey struct{}
63
64// Handler is de HTTP-handler met sessies en koppen.
65func (s *Server) Handler() http.Handler {
66 s.mustTemplates()
67 mux := http.NewServeMux()
68 mux.HandleFunc("GET /assets/{file}", s.asset)
69 mux.HandleFunc("GET /-/info", s.infoPage)
70 mux.HandleFunc("GET /api/v1/ci/spec", s.ciSpec)
71 mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
72 w.WriteHeader(http.StatusOK)
73 _, _ = w.Write([]byte("ok\n"))
74 })
75 mux.HandleFunc("GET /login", s.login)
76 mux.HandleFunc("GET /auth/callback", s.callback)
77 mux.HandleFunc("POST /logout", s.logout)
78 mux.HandleFunc("GET /{$}", s.home)
79 mux.HandleFunc("GET /new", s.newPage)
80 mux.HandleFunc("GET /new/slug", s.slugPreview)
81 mux.HandleFunc("POST /new/repo", s.createRepo)
82 mux.HandleFunc("POST /new/group", s.createGroup)
83 mux.HandleFunc("GET /setup", s.setupPage)
84 mux.HandleFunc("POST /setup", s.setupSave)
85 mux.HandleFunc("GET /settings", s.account)
86 mux.HandleFunc("POST /settings/language", s.saveLanguage)
87 mux.HandleFunc("POST /settings/tokens", s.createToken)
88 mux.HandleFunc("POST /settings/tokens/delete", s.deleteToken)
89 mux.HandleFunc("POST /settings/ssh", s.addSSH)
90 mux.HandleFunc("POST /settings/ssh/delete", s.deleteSSH)
91 mux.HandleFunc("GET /settings/export", s.export)
92 mux.HandleFunc("GET /users/{username}", s.profile)
93 mux.HandleFunc("GET /groups/{path}", s.groupPage)
94 mux.HandleFunc("GET /groups/{path}/logo", s.groupLogo)
95 mux.HandleFunc("POST /groups/{path}/settings", s.saveGroup)
96 mux.HandleFunc("POST /groups/{path}/approvals", s.saveGroupApproval)
97 mux.HandleFunc("POST /groups/{path}/owner", s.transferGroup)
98 mux.HandleFunc("POST /groups/{path}/logo", s.uploadGroupLogo)
99 mux.HandleFunc("POST /groups/{path}/members", s.groupMember)
100 mux.HandleFunc("POST /groups/{path}/members/remove", s.groupMemberRemove)
101 mux.HandleFunc("POST /groups/{path}/secrets", s.groupSecret)
102 mux.HandleFunc("POST /groups/{path}/secrets/delete", s.groupSecretDelete)
103 mux.HandleFunc("POST /groups/{path}/webhooks", s.groupWebhook)
104 mux.HandleFunc("POST /groups/{path}/webhooks/delete", s.groupWebhookDelete)
105
106 mux.HandleFunc("GET /{owner}/{repo}/info/refs", s.gitHTTP)
107 mux.HandleFunc("POST /{owner}/{repo}/git-upload-pack", s.gitHTTP)
108 mux.HandleFunc("POST /{owner}/{repo}/git-receive-pack", s.gitHTTP)
109 mux.HandleFunc("POST /api/v1/repos/{owner}/{repo}/releases", s.createRelease)
110
111 mux.HandleFunc("GET /{owner}/{repo}", s.repoHome)
112 mux.HandleFunc("GET /{owner}/{repo}/-/tree", s.treeRoot)
113 mux.HandleFunc("GET /{owner}/{repo}/-/tree/{path...}", s.tree)
114 mux.HandleFunc("GET /{owner}/{repo}/-/blob/{path...}", s.blob)
115 mux.HandleFunc("GET /{owner}/{repo}/-/commits", s.commits)
116 mux.HandleFunc("GET /{owner}/{repo}/-/tags", s.tags)
117 mux.HandleFunc("POST /{owner}/{repo}/-/tags", s.createTag)
118 mux.HandleFunc("POST /{owner}/{repo}/-/tags/delete", s.deleteTag)
119 mux.HandleFunc("GET /{owner}/{repo}/-/tags/archive", s.tagArchive)
120 mux.HandleFunc("GET /{owner}/{repo}/-/commit/{sha}", s.commit)
121 mux.HandleFunc("GET /{owner}/{repo}/-/branches", s.branches)
122 mux.HandleFunc("GET /{owner}/{repo}/-/merge-requests", s.mergeRequests)
123 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests", s.createMR)
124 mux.HandleFunc("GET /{owner}/{repo}/-/merge-requests/{number}", s.showMR)
125 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests/{number}/merge", s.mergeMR)
126 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests/{number}/close", s.closeMR)
127 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests/{number}/reopen", s.reopenMR)
128 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests/{number}/reviews", s.postReview)
129 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests/{number}/reviews/dismiss", s.dismissReview)
130 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests/{number}/notes", s.createNote)
131 mux.HandleFunc("POST /{owner}/{repo}/-/merge-requests/{number}/suggestions", s.applySuggestions)
132 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines", s.pipelines)
133 mux.HandleFunc("POST /{owner}/{repo}/-/pipelines", s.runPipeline)
134 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}", s.pipeline)
135 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}", s.showJob)
136 mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/log", s.jobLog)
137 mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/play", s.playJob)
138 mux.HandleFunc("GET /{owner}/{repo}/-/ci/editor", s.ciEditor)
139 mux.HandleFunc("POST /{owner}/{repo}/-/ci/editor", s.saveCIEditor)
140 mux.HandleFunc("POST /{owner}/{repo}/-/ci/lint", s.lintCI)
141 mux.HandleFunc("GET /{owner}/{repo}/-/releases", s.releases)
142 mux.HandleFunc("GET /{owner}/{repo}/-/releases/{tag}/assets/{name}", s.releaseAsset)
143 mux.HandleFunc("GET /{owner}/{repo}/-/logo", s.repoLogo)
144 mux.HandleFunc("POST /{owner}/{repo}/-/logo", s.uploadRepoLogo)
145 mux.HandleFunc("POST /{owner}/{repo}/-/star", s.toggleStar)
146 mux.HandleFunc("GET /{owner}/{repo}/-/settings", s.settings)
147 mux.HandleFunc("POST /{owner}/{repo}/-/settings", s.updateRepo)
148 mux.HandleFunc("POST /{owner}/{repo}/-/approvals", s.saveRepoApproval)
149 mux.HandleFunc("POST /{owner}/{repo}/-/members", s.repoMember)
150 mux.HandleFunc("POST /{owner}/{repo}/-/members/remove", s.repoMemberRemove)
151 mux.HandleFunc("POST /{owner}/{repo}/-/protected", s.addProtected)
152 mux.HandleFunc("POST /{owner}/{repo}/-/protected/remove", s.removeProtected)
153 mux.HandleFunc("POST /{owner}/{repo}/-/protected-tags", s.addProtectedTag)
154 mux.HandleFunc("POST /{owner}/{repo}/-/protected-tags/remove", s.removeProtectedTag)
155 mux.HandleFunc("POST /{owner}/{repo}/-/secrets", s.repoSecret)
156 mux.HandleFunc("POST /{owner}/{repo}/-/secrets/delete", s.repoSecretDelete)
157 mux.HandleFunc("POST /{owner}/{repo}/-/webhooks", s.repoWebhook)
158 mux.HandleFunc("POST /{owner}/{repo}/-/webhooks/delete", s.repoWebhookDelete)
159 mux.HandleFunc("POST /{owner}/{repo}/-/delete", s.deleteRepo)
160
161 return s.realIP(s.withSession(s.secure(s.gate(mux))))
162}
163
164func (s *Server) realIP(next http.Handler) http.Handler {
165 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
166 realip.Apply(r, s.Cfg.ProxySet())
167 next.ServeHTTP(w, r)
168 })
169}
170
171func (s *Server) mustTemplates() {
172 if s.byLang != nil {
173 return
174 }
175 s.byLang = map[string]*template.Template{}
176 for _, lang := range i18n.All() {
177 l := lang
178 s.byLang[string(l)] = template.Must(template.New("web").Funcs(template.FuncMap{
179 "short": func(v string) string {
180 if len(v) > 10 {
181 return v[:10]
182 }
183 return v
184 },
185 "join": strings.Join,
186 "initial": func(s string) string {
187 s = strings.TrimSpace(s)
188 if s == "" {
189 return "?"
190 }
191 r, _ := utf8.DecodeRuneInString(s)
192 return strings.ToUpper(string(r))
193 },
194 "splitPath": func(p string) []string {
195 if p == "" {
196 return nil
197 }
198 return strings.Split(p, "/")
199 },
200 "iconOf": func(name string) string { return fileIcon(name, "blob") },
201 "t": func(key string, args ...any) string { return i18n.T(l, key, args...) },
202 "tn": func(n int, one, many string) string {
203 key := many
204 if n == 1 {
205 key = one
206 }
207 return i18n.T(l, key, n)
208 },
209 "roleName": func(r access.Role) string { return i18n.T(l, "role."+string(r)) },
210 "visName": func(v string) string { return i18n.T(l, "vis."+v) },
211 "presetName": func(id string) string {
212 label := i18n.T(l, "set.preset."+id)
213 if label == "set.preset."+id {
214 return id
215 }
216 return label
217 },
218 }).ParseFS(webFS, "templates/*.html"))
219 }
220 s.tmpl = s.byLang[string(i18n.EN)]
221}
222
223func (s *Server) asset(w http.ResponseWriter, r *http.Request) {
224 name := r.PathValue("file")
225 if name == "" || strings.Contains(name, "/") || strings.Contains(name, "..") {
226 http.NotFound(w, r)
227 return
228 }
229 sub, err := fs.Sub(webFS, "static")
230 if err != nil {
231 http.Error(w, "assets", http.StatusInternalServerError)
232 return
233 }
234 http.ServeFileFS(w, r, sub, name)
235}
236
237func (s *Server) secure(next http.Handler) http.Handler {
238 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
239 w.Header().Set("X-Content-Type-Options", "nosniff")
240 w.Header().Set("X-Frame-Options", "DENY")
241 w.Header().Set("Referrer-Policy", "strict-origin-when-cross-origin")
242 w.Header().Set("Content-Security-Policy", "default-src 'self'; img-src 'self' https://auth.timfalken.com data:; style-src 'self'; form-action 'self'; base-uri 'self'; frame-ancestors 'none'")
243 next.ServeHTTP(w, r)
244 })
245}
246
247func (s *Server) withSession(next http.Handler) http.Handler {
248 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
249 p := principal{}
250 if c, err := r.Cookie("bluegit_session"); err == nil && c.Value != "" {
251 sess, err := s.Store.Session(r.Context(), c.Value)
252 if err == nil && sess.ExpiresAt.After(time.Now()) {
253 p.Session = sess
254 p.User = sess.User
255 p.OK = true
256 s.maybeExtend(r.Context(), sess)
257 }
258 }
259 next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), ctxKey{}, p)))
260 })
261}
262
263func (s *Server) maybeExtend(ctx context.Context, sess store.Session) {
264 if time.Until(sess.ExpiresAt) > 6*time.Hour {
265 return
266 }
267 sec, err := s.Auth.Extend(ctx, sess.AccessToken)
268 if err != nil || sec <= 0 {
269 return
270 }
271 _ = s.Store.UpdateSessionExpiry(ctx, sess.ID, time.Now().Add(time.Duration(sec)*time.Second))
272}
273
274func (s *Server) who(r *http.Request) principal {
275 p, _ := r.Context().Value(ctxKey{}).(principal)
276 return p
277}
278
279func (s *Server) csrfOK(w http.ResponseWriter, r *http.Request) bool {
280 if err := r.ParseForm(); err != nil {
281 http.Error(w, s.tr(r, "err.badForm"), http.StatusBadRequest)
282 return false
283 }
284 p := s.who(r)
285 if !p.OK || r.FormValue("csrf") == "" || r.FormValue("csrf") != p.Session.CSRF {
286 http.Error(w, s.tr(r, "err.badCSRF"), http.StatusBadRequest)
287 return false
288 }
289 return true
290}
291
292func (s *Server) loginRequired(w http.ResponseWriter, r *http.Request) (store.User, bool) {
293 p := s.who(r)
294 if !p.OK {
295 http.Redirect(w, r, "/login", http.StatusFound)
296 return store.User{}, false
297 }
298 return p.User, true
299}
300
301func (s *Server) setSessionCookie(w http.ResponseWriter, id string, exp time.Time) {
302 http.SetCookie(w, &http.Cookie{
303 Name: "bluegit_session",
304 Value: id,
305 Path: "/",
306 HttpOnly: true,
307 SameSite: http.SameSiteLaxMode,
308 Secure: strings.HasPrefix(s.Cfg.BaseURL, "https://"),
309 Expires: exp,
310 })
311}
312
313func (s *Server) flash(w http.ResponseWriter, notice, problem string) {
314 secure := strings.HasPrefix(s.Cfg.BaseURL, "https://")
315 if notice != "" {
316 http.SetCookie(w, &http.Cookie{Name: "bluegit_notice", Value: url.QueryEscape(notice), Path: "/", MaxAge: 120, HttpOnly: true, Secure: secure, SameSite: http.SameSiteLaxMode})
317 }
318 if problem != "" {
319 http.SetCookie(w, &http.Cookie{Name: "bluegit_error", Value: url.QueryEscape(problem), Path: "/", MaxAge: 120, HttpOnly: true, Secure: secure, SameSite: http.SameSiteLaxMode})
320 }
321}
322
323func (s *Server) takeFlash(w http.ResponseWriter, r *http.Request) (string, string) {
324 notice, problem := flashVal(r, "bluegit_notice"), flashVal(r, "bluegit_error")
325 if notice != "" {
326 http.SetCookie(w, &http.Cookie{Name: "bluegit_notice", Value: "", Path: "/", MaxAge: -1})
327 }
328 if problem != "" {
329 http.SetCookie(w, &http.Cookie{Name: "bluegit_error", Value: "", Path: "/", MaxAge: -1})
330 }
331 return notice, problem
332}
333
334func cookieVal(r *http.Request, name string) string {
335 c, err := r.Cookie(name)
336 if err != nil {
337 return ""
338 }
339 return c.Value
340}
341
342func flashVal(r *http.Request, name string) string {
343 raw := cookieVal(r, name)
344 if raw == "" {
345 return ""
346 }
347 v, err := url.QueryUnescape(raw)
348 if err != nil {
349 return raw
350 }
351 return v
352}
353
354func (s *Server) redirect(w http.ResponseWriter, r *http.Request, path, notice, problem string) {
355 s.flash(w, notice, problem)
356 http.Redirect(w, r, path, http.StatusSeeOther)
357}
358
359func (s *Server) langOf(r *http.Request) i18n.Lang {
360 if p := s.who(r); p.OK {
361 return i18n.Parse(p.User.Language)
362 }
363 return i18n.EN
364}
365
366func (s *Server) tr(r *http.Request, key string, args ...any) string {
367 return i18n.T(s.langOf(r), key, args...)
368}
369
370func (s *Server) trErr(r *http.Request, err error) string {
371 return i18n.Text(s.langOf(r), err)
372}
373
374func (s *Server) view(w http.ResponseWriter, r *http.Request, title string) View {
375 notice, problem := s.takeFlash(w, r)
376 lang := s.langOf(r)
377 if strings.HasPrefix(title, "title.") {
378 title = i18n.T(lang, title)
379 }
380 name := strings.TrimSpace(s.Cfg.Runner.Name)
381 if name == "" {
382 name = "Steve"
383 }
384 v := View{
385 Title: title, BaseURL: s.Cfg.BaseURL, RunnerName: name, Notice: notice, Err: problem,
386 StorageUnset: s.StoragePath() == "", Lang: string(lang), HTMLLang: htmlLang(lang),
387 Cunei: lang == i18n.Cuneiform,
388 }
389 for _, l := range i18n.All() {
390 v.Langs = append(v.Langs, LangChoice{Code: string(l), Label: l.Name()})
391 }
392 if p := s.who(r); p.OK {
393 u := p.User
394 v.User = &u
395 v.CSRF = p.Session.CSRF
396 }
397 return v
398}
399
400func htmlLang(l i18n.Lang) string {
401 switch l {
402 case i18n.NL:
403 return "nl"
404 case i18n.DE:
405 return "de"
406 case i18n.FR:
407 return "fr"
408 default:
409 return "en"
410 }
411}
412
413func (s *Server) render(w http.ResponseWriter, name string, v View) {
414 w.Header().Set("Content-Type", "text/html; charset=utf-8")
415 tmpl := s.byLang[v.Lang]
416 if tmpl == nil {
417 tmpl = s.tmpl
418 }
419 if err := tmpl.ExecuteTemplate(w, name, v); err != nil && s.Log != nil {
420 s.Log.Error("sjabloon", "name", name, "err", err)
421 }
422}
423
424func randomState() (string, error) {
425 b := make([]byte, 32)
426 if _, err := rand.Read(b); err != nil {
427 return "", err
428 }
429 return hex.EncodeToString(b), nil
430}
431
432// View is de gegevensset voor elk scherm.
433type View struct {
434 Title string
435 BaseURL string
436 RunnerName string
437 User *store.User
438 CSRF string
439 Notice string
440 Err string
441 Repos []store.Repo
442 Groups []store.Group
443 Repo *store.Repo
444 Role access.Role
445 CanWrite bool
446 CanAdmin bool
447 CanMerge bool
448 CanComment bool
449 CanApply bool
450 Commits []CommitRow
451 Commit *CommitRow
452 Entries []EntryRow
453 TreePath string
454 Blob string
455 BlobPath string
456 Binary bool
457 Branches []BranchRow
458 MRs []store.MergeRequest
459 MR *store.MergeRequest
460 MRPipe *PipeRow
461 MergeBlocks []string
462 Approval *ApprovalView
463 Reviews []ReviewRow
464 CanReview bool
465 CanApprove bool
466 CanDismiss bool
467 CanClose bool
468 CanReopen bool
469 IsOwner bool
470 Candidates []store.Member
471 Diff string
472 DiffFiles []DiffFileView
473 Pipes []store.Pipeline
474 PipeRows []PipeRow
475 Pipe *store.Pipeline
476 PipeStatus string
477 PipeLabel string
478 PipeJobs []JobLink
479 Live bool
480 LiveURL string
481 Jobs []store.Job
482 JobPage *JobPage
483 Editor *CIEditor
484 Releases []store.Release
485 Members []store.Member
486 Secrets []store.SecretMeta
487 Hooks []HookView
488 Patterns []string
489 TagPatterns []string
490 Tags []TagRow
491 Tokens []store.TokenInfo
492 Keys []store.SSHKey
493 CloneHTTP string
494 CloneSSH string
495 Group *store.Group
496 Tab string
497 Rev string
498 NewToken string
499 StorageUnset bool
500 StoragePath string
501 StorageFree string
502 StorageTotal string
503 MinFree string
504 Wide bool
505 Info bool
506 Spec cispec.Doc
507 SpecJSON template.JS
508 Page string
509 Lang string
510 HTMLLang string
511 Cunei bool
512 Langs []LangChoice
513 Query string
514 SortDir string
515 FlipDir string
516 Cards []RepoCard
517 Head *CommitRow
518 Files []FileRow
519 Tree []FileRow
520 Readme template.HTML
521 ReadmeName string
522 LicensePath string
523 NCommits int
524 NBranches int
525 NTags int
526 NReleases int
527 Created string
528 Lines []CodeLine
529 BlobSize string
530 FileName string
531 RevProtected bool
532 Heat *activity.Calendar
533 Notes []NoteRow
534 Profile *store.User
535}
536
537// LangChoice is één taal in de instellingen.
538type LangChoice struct {
539 Code, Label string
540}
541
542// RepoCard is een repository in een groepslijst.
543type RepoCard struct {
544 Repo store.Repo
545 Stars int
546 Starred bool
547 When string
548}
549
550// NoteRow is een reactie in de interface.
551type NoteRow struct {
552 ID int64
553 Author, Body, When, Path string
554 Start, End int
555 HasSuggestion bool
556}
557
558// DiffFileView is één bestand in de merge-request-diff.
559type DiffFileView struct {
560 Path string
561 Lines []DiffLineView
562}
563
564// DiffLineView is één diffregel, met de reacties die op het nieuwe regelnummer eindigen.
565type DiffLineView struct {
566 Kind string
567 Text string
568 Old int
569 New int
570 Notes []NoteRow
571}
572
573// TagRow is één tag op de tagspagina.
574type TagRow struct {
575 Name, Message, SHA, Short, Subject, Date string
576 Annotated, Protected, HasRelease, CanDelete bool
577 ZipURL, TarURL string
578}
579
580// FileRow is een rij in de bestandstabel of de boom.
581type FileRow struct {
582 Name, Path, Icon, Subject, When, SHA string
583 Dir bool
584 Depth int
585 Active bool
586}
587
588// CodeLine is één regel broncode.
589type CodeLine struct {
590 N int
591 HTML template.HTML
592}
593
594// CommitRow is een commit in de interface.
595// Author is de gekoppelde gebruiker, of anders de ruwe git-naam.
596// RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.
597type CommitRow struct {
598 SHA, Short, Author, Date, Subject, Body, When string
599 UserURL, Avatar, Initial, RawName, PushedBy string
600 PipeID int64
601 PipeStatus, PipeLabel string
602}
603
604// EntryRow is een bestand of map.
605type EntryRow struct {
606 Name, Type, Path string
607}
608
609// BranchRow is een branch, met of zonder bescherming.
610type BranchRow struct {
611 Name string
612 Protected bool
613}
614
615// HookView is een webhook plus de laatste pogingen.
616type HookView struct {
617 ID int64
618 Name string
619 Preset string
620 URL string
621 Method string
622 Filter string
623 Events string
624 Deliveries []store.Delivery
625}
626
627func repoURL(repo store.Repo) string { return "/" + repo.FullPath() }