From a848f3e793c9d497bf289f2332c8fd03d441cfc5 Mon Sep 17 00:00:00 2001 From: Joachim Hill-Grannec Date: Sat, 12 Aug 2017 17:01:10 -0700 Subject: [PATCH] allow in a patch update to change the build number if the user is an admin --- model/repo.go | 19 ++++++++++--------- server/repo.go | 5 ++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/model/repo.go b/model/repo.go index 4b1d1ef5..09496962 100644 --- a/model/repo.go +++ b/model/repo.go @@ -57,13 +57,14 @@ func (r *Repo) Update(from *Repo) { // RepoPatch represents a repository patch object. type RepoPatch struct { - Config *string `json:"config_file,omitempty"` - IsTrusted *bool `json:"trusted,omitempty"` - IsGated *bool `json:"gated,omitempty"` - Timeout *int64 `json:"timeout,omitempty"` - Visibility *string `json:"visibility,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"` + Config *string `json:"config_file,omitempty"` + IsTrusted *bool `json:"trusted,omitempty"` + IsGated *bool `json:"gated,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + Visibility *string `json:"visibility,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"` + BuildCounter *int `json:"build_counter,omitempty"` } diff --git a/server/repo.go b/server/repo.go index 8873729c..3f58b7de 100644 --- a/server/repo.go +++ b/server/repo.go @@ -95,7 +95,7 @@ func PatchRepo(c *gin.Context) { return } - if (in.IsTrusted != nil || in.Timeout != nil) && !user.Admin { + if (in.IsTrusted != nil || in.Timeout != nil || in.BuildCounter != nil) && !user.Admin { c.String(403, "Insufficient privileges") return } @@ -133,6 +133,9 @@ func PatchRepo(c *gin.Context) { return } } + if in.BuildCounter != nil { + repo.Counter = *in.BuildCounter + } err := store.UpdateRepo(c, repo) if err != nil {