BlueGit

timfa bluegit

Files

bluegit / internal / server / server.go

server.go

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