func ShowRepo(c *gin.Context) { user := session.User(c) repo := session.Repo(c) builds, _ := store.GetBuildList(c, repo) groups := []*model.BuildGroup{} var curr *model.BuildGroup for _, build := range builds { date := time.Unix(build.Created, 0).Format("Jan 2 2006") if curr == nil || curr.Date != date { curr = &model.BuildGroup{} curr.Date = date groups = append(groups, curr) } curr.Builds = append(curr.Builds, build) } httputil.SetCookie(c.Writer, c.Request, "user_last", repo.FullName) c.HTML(200, "repo.html", gin.H{ "User": user, "Repo": repo, "Builds": builds, "Groups": groups, }) }
func GetBuilds(c *gin.Context) { repo := session.Repo(c) builds, err := store.GetBuildList(c, repo) if err != nil { c.AbortWithStatus(http.StatusInternalServerError) return } c.IndentedJSON(http.StatusOK, builds) }
func GetCC(c *gin.Context) { repo, err := store.GetRepoOwnerName(c, c.Param("owner"), c.Param("name"), ) if err != nil { c.AbortWithStatus(404) return } builds, err := store.GetBuildList(c, repo) if err != nil || len(builds) == 0 { c.AbortWithStatus(404) return } url := fmt.Sprintf("%s/%s/%d", httputil.GetURL(c.Request), repo.FullName, builds[0].Number) cc := model.NewCC(repo, builds[0], url) c.XML(200, cc) }