summaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
diff options
context:
space:
mode:
authorChri-s <Chri-s@users.noreply.github.com>2018-03-13 04:46:14 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2018-03-13 11:46:14 +0800
commita2a49c93c78a81d1eaa6b0eaf84a0c3f4bcd2487 (patch)
treec59d836cbbc221d79c8d90c2f62775da680b6fef /routers/repo/issue.go
parentc0d41b1b77169553006bd9211d025de4da8bafd8 (diff)
downloadgitea-a2a49c93c78a81d1eaa6b0eaf84a0c3f4bcd2487.tar.gz
gitea-a2a49c93c78a81d1eaa6b0eaf84a0c3f4bcd2487.zip
Added checks for protected branches in pull requests (#3544)
* Added checks for protected branches in pull requests Signed-off-by: Christian Wulff <NChris@posteo.net> * Moved check for protected branch into new function CheckUserAllowedToMerge Signed-off-by: Christian Wulff <NChris@posteo.net> * Removed merge conflict lines from last commit Signed-off-by: Christian Wulff <NChris@posteo.net> * Explicit check for error type in ViewIssue Signed-off-by: Christian Wulff <NChris@posteo.net>
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 230b0e939d..a63572d5b6 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -734,6 +734,15 @@ func ViewIssue(ctx *context.Context) {
}
prConfig := prUnit.PullRequestsConfig()
+ ctx.Data["AllowMerge"] = ctx.Data["IsRepositoryWriter"]
+ if err := pull.CheckUserAllowedToMerge(ctx.User); err != nil {
+ if !models.IsErrNotAllowedToMerge(err) {
+ ctx.ServerError("CheckUserAllowedToMerge", err)
+ return
+ }
+ ctx.Data["AllowMerge"] = false
+ }
+
// Check correct values and select default
if ms, ok := ctx.Data["MergeStyle"].(models.MergeStyle); !ok ||
!prConfig.IsMergeStyleAllowed(ms) {