summaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-04-17 03:00:36 +0200
committerGitHub <noreply@github.com>2020-04-16 22:00:36 -0300
commitc52d48aae46af879fdfcfd94d03b7072878b5441 (patch)
tree8a3c5e7ab477059ceabd96a73ecb702602227c19 /routers/api/v1
parent2cb5878529992c1ffa6de2143d4a1e4673e33b1a (diff)
downloadgitea-c52d48aae46af879fdfcfd94d03b7072878b5441.tar.gz
gitea-c52d48aae46af879fdfcfd94d03b7072878b5441.zip
Prevent merge of outdated PRs on protected branches (#11012)
* Block PR on Outdated Branch * finalize * cleanup * fix typo and sentences thanks @guillep2k Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/repo/branch.go5
1 files changed, 5 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)