Skip to content

Commit 274f4ae

Browse files
authored
Fix a compare page 404 bug when the pull request disabled (#35441)
1 parent e35e724 commit 274f4ae

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
@@ -524,7 +524,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
524524

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

530530
if ctx.Data["PageIsComparePull"] == true && !permBase.CanReadIssuesOrPulls(true) {
@@ -730,6 +730,7 @@ func CompareDiff(ctx *context.Context) {
730730
return
731731
}
732732

733+
ctx.Data["PageIsViewCode"] = true
733734
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
734735
ctx.Data["DirectComparison"] = ci.DirectComparison
735736
ctx.Data["OtherCompareSeparator"] = ".."

0 commit comments

Comments
 (0)