From 5bdb6ffc585780a862e9c3024331b0726e00f8b7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 9 Nov 2021 14:05:37 +0800 Subject: [PATCH] Fix 500 when review pull request with anonymous --- routers/web/repo/issue.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 0816d413400c5..72c12133f8a88 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1545,6 +1545,10 @@ func ViewIssue(ctx *context.Context) { } ctx.Data["ShowMergeInstructions"] = true if pull.ProtectedBranch != nil { + var showMergeInstructions bool + if ctx.User != nil { + showMergeInstructions = pull.ProtectedBranch.CanUserPush(ctx.User.ID) + } cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull) ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull) ctx.Data["IsBlockedByRejection"] = pull.ProtectedBranch.MergeBlockedByRejectedReview(pull) @@ -1555,7 +1559,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0 ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles) - ctx.Data["ShowMergeInstructions"] = pull.ProtectedBranch.CanUserPush(ctx.User.ID) + ctx.Data["ShowMergeInstructions"] = showMergeInstructions } ctx.Data["WillSign"] = false if ctx.User != nil {