Skip to content

Commit 67977f0

Browse files
GiteaBotlunny
andauthored
Fix a compare page 404 bug when the pull request disabled (#35441) (#35453)
Backport #35441 by @lunny Co-authored-by: Lunny Xiao <[email protected]>
1 parent 78fbcf3 commit 67977f0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

routers/web/repo/compare.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
523523

524524
// Treat as pull request if both references are branches
525525
if ctx.Data["PageIsComparePull"] == nil {
526-
ctx.Data["PageIsComparePull"] = headIsBranch && baseIsBranch
526+
ctx.Data["PageIsComparePull"] = headIsBranch && baseIsBranch && permBase.CanReadIssuesOrPulls(true)
527527
}
528528

529529
if ctx.Data["PageIsComparePull"] == true && !permBase.CanReadIssuesOrPulls(true) {
@@ -735,6 +735,7 @@ func CompareDiff(ctx *context.Context) {
735735
return
736736
}
737737

738+
ctx.Data["PageIsViewCode"] = true
738739
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
739740
ctx.Data["DirectComparison"] = ci.DirectComparison
740741
ctx.Data["OtherCompareSeparator"] = ".."

0 commit comments

Comments
 (0)