Skip to content

Commit d6d147c

Browse files
authored
Fix 500 when review pull request with anonymous (#17594)
1 parent 062b051 commit d6d147c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

routers/web/repo/issue.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,10 @@ func ViewIssue(ctx *context.Context) {
15451545
}
15461546
ctx.Data["ShowMergeInstructions"] = true
15471547
if pull.ProtectedBranch != nil {
1548+
var showMergeInstructions bool
1549+
if ctx.User != nil {
1550+
showMergeInstructions = pull.ProtectedBranch.CanUserPush(ctx.User.ID)
1551+
}
15481552
cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull)
15491553
ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull)
15501554
ctx.Data["IsBlockedByRejection"] = pull.ProtectedBranch.MergeBlockedByRejectedReview(pull)
@@ -1555,7 +1559,7 @@ func ViewIssue(ctx *context.Context) {
15551559
ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles
15561560
ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0
15571561
ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles)
1558-
ctx.Data["ShowMergeInstructions"] = pull.ProtectedBranch.CanUserPush(ctx.User.ID)
1562+
ctx.Data["ShowMergeInstructions"] = showMergeInstructions
15591563
}
15601564
ctx.Data["WillSign"] = false
15611565
if ctx.User != nil {

0 commit comments

Comments
 (0)