internal/httpd/builds.go
45 lines · 824 bytes
1package httpd
2
3import (
4 "net/http"
5 "strconv"
6
7 "gitbay.org/gitbay/internal/store"
8)
9
10func (s *Server) builds(w http.ResponseWriter, r *http.Request) {
11 p, ok := s.repoFor(w, r, "")
12 if !ok {
13 return
14 }
15 p.Tab = "builds"
16 builds, _ := s.st.ListBuilds(p.Repo.ID, 50)
17 s.render(w, "builds.html", struct {
18 repoPage
19 Builds []store.Build
20 }{p, builds})
21}
22
23func (s *Server) build(w http.ResponseWriter, r *http.Request) {
24 p, ok := s.repoFor(w, r, "")
25 if !ok {
26 return
27 }
28 p.Tab = "builds"
29 n, err := strconv.ParseInt(r.PathValue("n"), 10, 64)
30 if err != nil {
31 s.notFound(w, r)
32 return
33 }
34 b, err := s.st.BuildByNumber(p.Repo.ID, n)
35 if err != nil {
36 s.notFound(w, r)
37 return
38 }
39 log, _ := s.st.BuildLog(b.ID)
40 s.render(w, "build.html", struct {
41 repoPage
42 Build store.Build
43 Log string
44 }{p, b, string(log)})
45}