func ChownRepo(c *gin.Context) { repo := session.Repo(c) user := session.User(c) repo.UserID = user.ID err := store.UpdateRepo(c, repo) if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } c.JSON(http.StatusOK, repo) }
func PatchRepo(c *gin.Context) { repo := session.Repo(c) user := session.User(c) in := &struct { IsTrusted *bool `json:"trusted,omitempty"` Timeout *int64 `json:"timeout,omitempty"` AllowPull *bool `json:"allow_pr,omitempty"` AllowPush *bool `json:"allow_push,omitempty"` AllowDeploy *bool `json:"allow_deploy,omitempty"` AllowTag *bool `json:"allow_tag,omitempty"` }{} if err := c.Bind(in); err != nil { c.AbortWithError(http.StatusBadRequest, err) return } if in.AllowPush != nil { repo.AllowPush = *in.AllowPush } if in.AllowPull != nil { repo.AllowPull = *in.AllowPull } if in.AllowDeploy != nil { repo.AllowDeploy = *in.AllowDeploy } if in.AllowTag != nil { repo.AllowTag = *in.AllowTag } if in.IsTrusted != nil && user.Admin { repo.IsTrusted = *in.IsTrusted } if in.Timeout != nil && user.Admin { repo.Timeout = *in.Timeout } err := store.UpdateRepo(c, repo) if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } c.JSON(http.StatusOK, repo) }