diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/branch.go | 5 | ||||
-rw-r--r-- | routers/private/hook.go | 1 | ||||
-rw-r--r-- | routers/repo/issue.go | 1 | ||||
-rw-r--r-- | routers/repo/setting_protected_branch.go | 1 |
4 files changed, 8 insertions, 0 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index 56a9b5ec25..07c6159501 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -340,6 +340,7 @@ func CreateBranchProtection(ctx *context.APIContext, form api.CreateBranchProtec DismissStaleApprovals: form.DismissStaleApprovals, RequireSignedCommits: form.RequireSignedCommits, ProtectedFilePatterns: form.ProtectedFilePatterns, + BlockOnOutdatedBranch: form.BlockOnOutdatedBranch, } err = models.UpdateProtectBranch(ctx.Repo.Repository, protectBranch, models.WhitelistOptions{ @@ -475,6 +476,10 @@ func EditBranchProtection(ctx *context.APIContext, form api.EditBranchProtection protectBranch.ProtectedFilePatterns = *form.ProtectedFilePatterns } + if form.BlockOnOutdatedBranch != nil { + protectBranch.BlockOnOutdatedBranch = *form.BlockOnOutdatedBranch + } + var whitelistUsers []int64 if form.PushWhitelistUsernames != nil { whitelistUsers, err = models.GetUserIDsByNames(form.PushWhitelistUsernames, false) diff --git a/routers/private/hook.go b/routers/private/hook.go index 846d9b6070..de2b03e0b2 100644 --- a/routers/private/hook.go +++ b/routers/private/hook.go @@ -263,6 +263,7 @@ func HookPreReceive(ctx *macaron.Context, opts private.HookOptions) { } } + // Detect Protected file pattern globs := protectBranch.GetProtectedFilePatterns() if len(globs) > 0 { err := checkFileProtection(oldCommitID, newCommitID, globs, gitRepo, env) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 3655de7ed4..9ad379684a 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1065,6 +1065,7 @@ func ViewIssue(ctx *context.Context) { cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull) ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull) ctx.Data["IsBlockedByRejection"] = pull.ProtectedBranch.MergeBlockedByRejectedReview(pull) + ctx.Data["IsBlockedByOutdatedBranch"] = pull.ProtectedBranch.MergeBlockedByOutdatedBranch(pull) ctx.Data["GrantedApprovals"] = cnt ctx.Data["RequireSigned"] = pull.ProtectedBranch.RequireSignedCommits } diff --git a/routers/repo/setting_protected_branch.go b/routers/repo/setting_protected_branch.go index af49aefcec..ab0fd77eee 100644 --- a/routers/repo/setting_protected_branch.go +++ b/routers/repo/setting_protected_branch.go @@ -248,6 +248,7 @@ func SettingsProtectedBranchPost(ctx *context.Context, f auth.ProtectBranchForm) protectBranch.DismissStaleApprovals = f.DismissStaleApprovals protectBranch.RequireSignedCommits = f.RequireSignedCommits protectBranch.ProtectedFilePatterns = f.ProtectedFilePatterns + protectBranch.BlockOnOutdatedBranch = f.BlockOnOutdatedBranch err = models.UpdateProtectBranch(ctx.Repo.Repository, protectBranch, models.WhitelistOptions{ UserIDs: whitelistUsers, |