summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorChri-s <Chri-s@users.noreply.github.com>2018-03-25 12:01:32 +0200
committerLauris BH <lauris@nix.lv>2018-03-25 13:01:32 +0300
commit9350ba7947d8caa6e7338d7c9e54df2f3aef2146 (patch)
treee40e1f9810c03221073742040c7fc2c93b3b7546 /routers
parent04b7fd87b9d74aa6a0c559ac218546978bbf6f33 (diff)
downloadgitea-9350ba7947d8caa6e7338d7c9e54df2f3aef2146.tar.gz
gitea-9350ba7947d8caa6e7338d7c9e54df2f3aef2146.zip
Add protected branch whitelists for merging (#3689)
* Add database migrations for merge whitelist * Add merge whitelist settings for protected branches * Add checks for merge whitelists
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/setting_protected_branch.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/routers/repo/setting_protected_branch.go b/routers/repo/setting_protected_branch.go
index ac1017b91f..db12f0afcd 100644
--- a/routers/repo/setting_protected_branch.go
+++ b/routers/repo/setting_protected_branch.go
@@ -123,6 +123,7 @@ func SettingsProtectedBranch(c *context.Context) {
}
c.Data["Users"] = users
c.Data["whitelist_users"] = strings.Join(base.Int64sToStrings(protectBranch.WhitelistUserIDs), ",")
+ c.Data["merge_whitelist_users"] = strings.Join(base.Int64sToStrings(protectBranch.MergeWhitelistUserIDs), ",")
if c.Repo.Owner.IsOrganization() {
teams, err := c.Repo.Owner.TeamsWithAccessToRepo(c.Repo.Repository.ID, models.AccessModeWrite)
@@ -132,6 +133,7 @@ func SettingsProtectedBranch(c *context.Context) {
}
c.Data["Teams"] = teams
c.Data["whitelist_teams"] = strings.Join(base.Int64sToStrings(protectBranch.WhitelistTeamIDs), ",")
+ c.Data["merge_whitelist_teams"] = strings.Join(base.Int64sToStrings(protectBranch.MergeWhitelistTeamIDs), ",")
}
c.Data["Branch"] = protectBranch
@@ -166,7 +168,10 @@ func SettingsProtectedBranchPost(ctx *context.Context, f auth.ProtectBranchForm)
protectBranch.EnableWhitelist = f.EnableWhitelist
whitelistUsers, _ := base.StringsToInt64s(strings.Split(f.WhitelistUsers, ","))
whitelistTeams, _ := base.StringsToInt64s(strings.Split(f.WhitelistTeams, ","))
- err = models.UpdateProtectBranch(ctx.Repo.Repository, protectBranch, whitelistUsers, whitelistTeams)
+ protectBranch.EnableMergeWhitelist = f.EnableMergeWhitelist
+ mergeWhitelistUsers, _ := base.StringsToInt64s(strings.Split(f.MergeWhitelistUsers, ","))
+ mergeWhitelistTeams, _ := base.StringsToInt64s(strings.Split(f.MergeWhitelistTeams, ","))
+ err = models.UpdateProtectBranch(ctx.Repo.Repository, protectBranch, whitelistUsers, whitelistTeams, mergeWhitelistUsers, mergeWhitelistTeams)
if err != nil {
ctx.ServerError("UpdateProtectBranch", err)
return