mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Fix 500 when review pull request with anonymous (#17594)
This commit is contained in:
		| @@ -1545,6 +1545,10 @@ func ViewIssue(ctx *context.Context) { | |||||||
| 		} | 		} | ||||||
| 		ctx.Data["ShowMergeInstructions"] = true | 		ctx.Data["ShowMergeInstructions"] = true | ||||||
| 		if pull.ProtectedBranch != nil { | 		if pull.ProtectedBranch != nil { | ||||||
|  | 			var showMergeInstructions bool | ||||||
|  | 			if ctx.User != nil { | ||||||
|  | 				showMergeInstructions = pull.ProtectedBranch.CanUserPush(ctx.User.ID) | ||||||
|  | 			} | ||||||
| 			cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull) | 			cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull) | ||||||
| 			ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull) | 			ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull) | ||||||
| 			ctx.Data["IsBlockedByRejection"] = pull.ProtectedBranch.MergeBlockedByRejectedReview(pull) | 			ctx.Data["IsBlockedByRejection"] = pull.ProtectedBranch.MergeBlockedByRejectedReview(pull) | ||||||
| @@ -1555,7 +1559,7 @@ func ViewIssue(ctx *context.Context) { | |||||||
| 			ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles | 			ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles | ||||||
| 			ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0 | 			ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0 | ||||||
| 			ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles) | 			ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles) | ||||||
| 			ctx.Data["ShowMergeInstructions"] = pull.ProtectedBranch.CanUserPush(ctx.User.ID) | 			ctx.Data["ShowMergeInstructions"] = showMergeInstructions | ||||||
| 		} | 		} | ||||||
| 		ctx.Data["WillSign"] = false | 		ctx.Data["WillSign"] = false | ||||||
| 		if ctx.User != nil { | 		if ctx.User != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lunny Xiao
					Lunny Xiao