From 0e77e20a81ddb45ff6d8a3a0e99666d4ee093b15 Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Wed, 19 Apr 2023 23:16:46 +0800
Subject: [PATCH] Don't list root repository on compare page if pulls not
 allowed (#24183)

Fix #24165
---
 routers/web/repo/compare.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index f63693e72e45a..2e481cc672bba 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -459,7 +459,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
 		rootRepo.ID != ci.HeadRepo.ID &&
 		rootRepo.ID != baseRepo.ID {
 		canRead := access_model.CheckRepoUnitUser(ctx, rootRepo, ctx.Doer, unit.TypeCode)
-		if canRead {
+		if canRead && rootRepo.AllowsPulls() {
 			ctx.Data["RootRepo"] = rootRepo
 			if !fileOnly {
 				branches, tags, err := getBranchesAndTagsForRepo(ctx, rootRepo)