From 0b77dbc11c6e8fbda79766dd578d2e1735228c4d Mon Sep 17 00:00:00 2001
From: Ethan Koenig <ethantkoenig@gmail.com>
Date: Tue, 12 Dec 2017 21:06:25 -0800
Subject: [PATCH] Fix new pull request link (#3133)

* Fix new pull request link

* Only show button for branches
---
 modules/context/repo.go  | 1 -
 templates/repo/home.tmpl | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/modules/context/repo.go b/modules/context/repo.go
index 7651d43fad..a60f81b4d5 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -427,7 +427,6 @@ func RepoAssignment() macaron.Handler {
 				return
 			}
 		}
-		ctx.Data["IsForkedRepo"] = repo.IsFork
 
 		// People who have push access or have forked repository can propose a new pull request.
 		if ctx.Repo.IsWriter() || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) {
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index 0db8f37320..4799e84a21 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -25,9 +25,9 @@
 		</div>
 		{{template "repo/sub_menu" .}}
 		<div class="ui secondary menu">
-			{{if .PullRequestCtx.Allowed}}
+			{{if and .PullRequestCtx.Allowed .IsViewBranch}}
 				<div class="fitted item">
-					<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch}}...{{if .IsForkedRepo}}{{.Repository.Owner.Name}}:{{else}}{{if .SignedUser.HasForkedRepo .BaseRepo.ID}}{{.SignedUser.Name}}:{{end}}{{end}}{{.BranchName}}">
+					<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch}}...{{.Repository.Owner.Name}}:{{.BranchName}}">
 						<button class="ui green tiny compact button"><i class="octicon octicon-git-compare"></i></button>
 					</a>
 				</div>