From 67977f0b1c7a98f9f758f0efd341636478ed9e4e Mon Sep 17 00:00:00 2001 From: Giteabot Date: Wed, 10 Sep 2025 22:39:50 +0800 Subject: [PATCH] Fix a compare page 404 bug when the pull request disabled (#35441) (#35453) Backport #35441 by @lunny Co-authored-by: Lunny Xiao --- 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 c771b30e5f..c7c048d516 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -523,7 +523,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) { @@ -735,6 +735,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"] = ".."