BlueGit

timfa bluegit

Files

bluegit / internal / server / server.go

server.go

feat: toon een commit zoals GitLab
timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa · 3 weeks ago
dc9d9b26 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 CommitDiff *CommitDiff
453 Entries []EntryRow
454 TreePath string
455 Blob string
456 BlobPath string
457 Binary bool
458 Branches []BranchRow
459 MRs []store.MergeRequest
460 MR *store.MergeRequest
461 MRPipe *PipeRow
462 MergeBlocks []string
463 Approval *ApprovalView
464 Reviews []ReviewRow
465 CanReview bool
466 CanApprove bool
467 CanDismiss bool
468 CanClose bool
469 CanReopen bool
470 IsOwner bool
471 Candidates []store.Member
472 Diff string
473 DiffFiles []DiffFileView
474 Pipes []store.Pipeline
475 PipeRows []PipeRow
476 Pipe *store.Pipeline
477 PipeStatus string
478 PipeLabel string
479 PipeJobs []JobLink
480 Live bool
481 LiveURL string
482 Jobs []store.Job
483 JobPage *JobPage
484 Editor *CIEditor
485 Releases []store.Release
486 Members []store.Member
487 Secrets []store.SecretMeta
488 Hooks []HookView
489 Patterns []string
490 TagPatterns []string
491 Tags []TagRow
492 Tokens []store.TokenInfo
493 Keys []store.SSHKey
494 CloneHTTP string
495 CloneSSH string
496 Group *store.Group
497 Tab string
498 Rev string
499 NewToken string
500 StorageUnset bool
501 StoragePath string
502 StorageFree string
503 StorageTotal string
504 MinFree string
505 Wide bool
506 Info bool
507 Spec cispec.Doc
508 SpecJSON template.JS
509 Page string
510 Lang string
511 HTMLLang string
512 Cunei bool
513 Langs []LangChoice
514 Query string
515 SortDir string
516 FlipDir string
517 Cards []RepoCard
518 Head *CommitRow
519 Files []FileRow
520 Tree []FileRow
521 Readme template.HTML
522 ReadmeName string
523 LicensePath string
524 NCommits int
525 NBranches int
526 NTags int
527 NReleases int
528 Created string
529 Lines []CodeLine
530 BlobSize string
531 FileName string
532 RevProtected bool
533 Heat *activity.Calendar
534 Notes []NoteRow
535 Profile *store.User
536}
537
538// LangChoice is één taal in de instellingen.
539type LangChoice struct {
540 Code, Label string
541}
542
543// RepoCard is een repository in een groepslijst.
544type RepoCard struct {
545 Repo store.Repo
546 Stars int
547 Starred bool
548 When string
549}
550
551// NoteRow is een reactie in de interface.
552type NoteRow struct {
553 ID int64
554 Author, Body, When, Path string
555 Start, End int
556 HasSuggestion bool
557}
558
559// DiffFileView is één bestand in de merge-request-diff.
560type DiffFileView struct {
561 Path string
562 Lines []DiffLineView
563}
564
565// DiffLineView is één diffregel, met de reacties die op het nieuwe regelnummer eindigen.
566type DiffLineView struct {
567 Kind string
568 Text string
569 Old int
570 New int
571 Notes []NoteRow
572}
573
574// TagRow is één tag op de tagspagina.
575type TagRow struct {
576 Name, Message, SHA, Short, Subject, Date string
577 Annotated, Protected, HasRelease, CanDelete bool
578 ZipURL, TarURL string
579}
580
581// FileRow is een rij in de bestandstabel of de boom.
582type FileRow struct {
583 Name, Path, Icon, Subject, When, SHA string
584 Dir bool
585 Depth int
586 Active bool
587}
588
589// CodeLine is één regel broncode.
590type CodeLine struct {
591 N int
592 HTML template.HTML
593}
594
595// CommitRow is een commit in de interface.
596// Author is de gekoppelde gebruiker, of anders de ruwe git-naam.
597// RawName en PushedBy zijn gezet als de pusher de fallback is en de git-naam afwijkt.
598type CommitRow struct {
599 SHA, Short, Author, Date, Subject, Body, When string
600 UserURL, Avatar, Initial, RawName, PushedBy string
601 PipeID int64
602 PipeStatus, PipeLabel string
603}
604
605// EntryRow is een bestand of map.
606type EntryRow struct {
607 Name, Type, Path string
608}
609
610// BranchRow is een branch, met of zonder bescherming.
611type BranchRow struct {
612 Name string
613 Protected bool
614}
615
616// HookView is een webhook plus de laatste pogingen.
617type HookView struct {
618 ID int64
619 Name string
620 Preset string
621 URL string
622 Method string
623 Filter string
624 Events string
625 Deliveries []store.Delivery
626}
627
628func repoURL(repo store.Repo) string { return "/" + repo.FullPath() }