From 072bdfa3f50591863d523202e6d8a0fac0ca7ea7 Mon Sep 17 00:00:00 2001
From: Gary Kim <gary@garykim.dev>
Date: Thu, 11 Jul 2019 20:21:16 +0000
Subject: [PATCH] Only show "New Pull Request" button if repo allows pulls
 (#7426)

Signed-off-by: Gary Kim <gary@garykim.dev>
---
 routers/repo/branch.go          | 1 +
 templates/repo/branch/list.tmpl | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/routers/repo/branch.go b/routers/repo/branch.go
index 708b33be09..3bd4a75bfb 100644
--- a/routers/repo/branch.go
+++ b/routers/repo/branch.go
@@ -39,6 +39,7 @@ func Branches(ctx *context.Context) {
 	ctx.Data["Title"] = "Branches"
 	ctx.Data["IsRepoToolbarBranches"] = true
 	ctx.Data["DefaultBranch"] = ctx.Repo.Repository.DefaultBranch
+	ctx.Data["AllowsPulls"] = ctx.Repo.Repository.AllowsPulls()
 	ctx.Data["IsWriter"] = ctx.Repo.CanWrite(models.UnitTypeCode)
 	ctx.Data["IsMirror"] = ctx.Repo.Repository.IsMirror
 	ctx.Data["PageIsViewCode"] = true
diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl
index a2fb5c2069..2028797bdb 100644
--- a/templates/repo/branch/list.tmpl
+++ b/templates/repo/branch/list.tmpl
@@ -63,7 +63,7 @@
 									</td>
 									<td class="right aligned">
 										{{if not .LatestPullRequest}}
-											{{if not .IsDeleted}}
+											{{if and (not .IsDeleted) $.AllowsPulls}}
 											<a href="{{$.RepoLink}}/compare/{{$.DefaultBranch | EscapePound}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{$.Owner.Name}}:{{end}}{{.Name | EscapePound}}">
 												<button id="new-pull-request" class="ui compact basic button">{{$.i18n.Tr "repo.pulls.compare_changes"}}</button>
 											</a>