diff options
author | David Svantesson <davidsvantesson@gmail.com> | 2020-01-03 18:47:10 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2020-01-03 19:47:09 +0200 |
commit | ea707f5a77d83d023cb02ce8e44c4b95ac83ef30 (patch) | |
tree | fdebe0cc3d2b0e41cf8c7932ae446a2e3c500bbc /routers/repo | |
parent | b39fab41c8b315ba7ddf9f9a4cc522385cf9f720 (diff) | |
download | gitea-ea707f5a77d83d023cb02ce8e44c4b95ac83ef30.tar.gz gitea-ea707f5a77d83d023cb02ce8e44c4b95ac83ef30.zip |
Add branch protection option to block merge on requested changes. (#9592)
* Add branch protection option to block merge on requested changes.
* Add migration step
* Fix check to correct negation
* Apply suggestions from code review
Language improvement.
Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com>
* Copyright year.
Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/issue.go | 3 | ||||
-rw-r--r-- | routers/repo/setting_protected_branch.go | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 925903fee4..46020acb6d 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -962,7 +962,8 @@ func ViewIssue(ctx *context.Context) { } if pull.ProtectedBranch != nil { cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull) - ctx.Data["IsBlockedByApprovals"] = pull.ProtectedBranch.RequiredApprovals > 0 && cnt < pull.ProtectedBranch.RequiredApprovals + ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull) + ctx.Data["IsBlockedByRejection"] = pull.ProtectedBranch.MergeBlockedByRejectedReview(pull) ctx.Data["GrantedApprovals"] = cnt } ctx.Data["IsPullBranchDeletable"] = canDelete && pull.HeadRepo != nil && git.IsBranchExist(pull.HeadRepo.RepoPath(), pull.HeadBranch) diff --git a/routers/repo/setting_protected_branch.go b/routers/repo/setting_protected_branch.go index c279c94b1b..8872c7471f 100644 --- a/routers/repo/setting_protected_branch.go +++ b/routers/repo/setting_protected_branch.go @@ -244,6 +244,7 @@ func SettingsProtectedBranchPost(ctx *context.Context, f auth.ProtectBranchForm) approvalsWhitelistTeams, _ = base.StringsToInt64s(strings.Split(f.ApprovalsWhitelistTeams, ",")) } } + protectBranch.BlockOnRejectedReviews = f.BlockOnRejectedReviews err = models.UpdateProtectBranch(ctx.Repo.Repository, protectBranch, models.WhitelistOptions{ UserIDs: whitelistUsers, |