aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/pull.go
diff options
context:
space:
mode:
authorDavid Svantesson <davidsvantesson@gmail.com>2020-01-11 08:29:34 +0100
committertechknowlogick <techknowlogick@gitea.io>2020-01-11 02:29:34 -0500
commit32fb813133c74ddc3af1964e81fff72fea4f24f1 (patch)
tree31eec446f12e448d7cf398db43620606e9704ff1 /routers/repo/pull.go
parent4d06d10dbafe7cfd404889b636d8e243058ee96f (diff)
downloadgitea-32fb813133c74ddc3af1964e81fff72fea4f24f1.tar.gz
gitea-32fb813133c74ddc3af1964e81fff72fea4f24f1.zip
Allow repo admin to merge PR regardless of review status (#9611)
* Allow repo admin to merge even if review is not ok.
Diffstat (limited to 'routers/repo/pull.go')
-rw-r--r--routers/repo/pull.go32
1 files changed, 23 insertions, 9 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 93e98e0c33..901ab48856 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -600,6 +600,16 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
pr := issue.PullRequest
+ allowedMerge, err := pull_service.IsUserAllowedToMerge(pr, ctx.Repo.Permission, ctx.User)
+ if err != nil {
+ ctx.ServerError("IsUserAllowedToMerge", err)
+ return
+ }
+ if !allowedMerge {
+ ctx.NotFound("MergePullRequest", nil)
+ return
+ }
+
if !pr.CanAutoMerge() || pr.HasMerged {
ctx.NotFound("MergePullRequest", nil)
return
@@ -611,15 +621,19 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
return
}
- isPass, err := pull_service.IsPullCommitStatusPass(pr)
- if err != nil {
- ctx.ServerError("IsPullCommitStatusPass", err)
- return
- }
- if !isPass && !ctx.IsUserRepoAdmin() {
- ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_status_check"))
- ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
- return
+ if err := pull_service.CheckPRReadyToMerge(pr); err != nil {
+ if !models.IsErrNotAllowedToMerge(err) {
+ ctx.ServerError("Merge PR status", err)
+ return
+ }
+ if isRepoAdmin, err := models.IsUserRepoAdmin(pr.BaseRepo, ctx.User); err != nil {
+ ctx.ServerError("IsUserRepoAdmin", err)
+ return
+ } else if !isRepoAdmin {
+ ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready"))
+ ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
+ return
+ }
}
if ctx.HasError() {