From 274f4aea7e944128b9ed033fade20caafbb8fca8 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 9 Sep 2025 21:04:32 -0700 Subject: [PATCH] Fix a compare page 404 bug when the pull request disabled (#35441) --- routers/web/repo/compare.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 20f5d6262e..a7084bf0ae 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -524,7 +524,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo { // Treat as pull request if both references are branches if ctx.Data["PageIsComparePull"] == nil { - ctx.Data["PageIsComparePull"] = headIsBranch && baseIsBranch + ctx.Data["PageIsComparePull"] = headIsBranch && baseIsBranch && permBase.CanReadIssuesOrPulls(true) } if ctx.Data["PageIsComparePull"] == true && !permBase.CanReadIssuesOrPulls(true) { @@ -730,6 +730,7 @@ func CompareDiff(ctx *context.Context) { return } + ctx.Data["PageIsViewCode"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes ctx.Data["DirectComparison"] = ci.DirectComparison ctx.Data["OtherCompareSeparator"] = ".."