diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-09 21:14:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 13:14:12 +0000 |
commit | d6d147c2c42c834b370f91477a40e5e79d1d220c (patch) | |
tree | d56c96ba201767dccacd4374a00db7c443dcb712 /routers/web/repo/issue.go | |
parent | 062b051687d4d9423288fb6c7acf38041e4df0b4 (diff) | |
download | gitea-d6d147c2c42c834b370f91477a40e5e79d1d220c.tar.gz gitea-d6d147c2c42c834b370f91477a40e5e79d1d220c.zip |
Fix 500 when review pull request with anonymous (#17594)
Diffstat (limited to 'routers/web/repo/issue.go')
-rw-r--r-- | routers/web/repo/issue.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 8f09f95172..2782e8d629 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 { |