diff options
author | 6543 <6543@obermui.de> | 2020-04-17 03:00:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 22:00:36 -0300 |
commit | c52d48aae46af879fdfcfd94d03b7072878b5441 (patch) | |
tree | 8a3c5e7ab477059ceabd96a73ecb702602227c19 /services/pull/merge.go | |
parent | 2cb5878529992c1ffa6de2143d4a1e4673e33b1a (diff) | |
download | gitea-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 'services/pull/merge.go')
-rw-r--r-- | services/pull/merge.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/services/pull/merge.go b/services/pull/merge.go index a20a214014..47521ce147 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -574,16 +574,22 @@ func CheckPRReadyToMerge(pr *models.PullRequest) (err error) { } } - if enoughApprovals := pr.ProtectedBranch.HasEnoughApprovals(pr); !enoughApprovals { + if !pr.ProtectedBranch.HasEnoughApprovals(pr) { return models.ErrNotAllowedToMerge{ Reason: "Does not have enough approvals", } } - if rejected := pr.ProtectedBranch.MergeBlockedByRejectedReview(pr); rejected { + if pr.ProtectedBranch.MergeBlockedByRejectedReview(pr) { return models.ErrNotAllowedToMerge{ Reason: "There are requested changes", } } + if pr.ProtectedBranch.MergeBlockedByOutdatedBranch(pr) { + return models.ErrNotAllowedToMerge{ + Reason: "The head branch is behind the base branch", + } + } + return nil } |