mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-24 14:25:02 +02:00
fix(pulls): tolerate invalid stored review commit_id (#39849)
Fixes #39848 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
1 parent
edd0c0e2ce
commit
35fa0400e9
10 files changed
+196
-136
No files matched your search
+18
-15
@@ -885,24 +885,27 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
}
|
||||
ctx.Data["Assignees"] = shared_user.MakeSelfOnTop(ctx.Doer, assigneeUsers)
|
||||
|
||||
currentReview, err := issues_model.GetCurrentReview(ctx, ctx.Doer, issue)
|
||||
if err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
ctx.ServerError("GetCurrentReview", err)
|
||||
return
|
||||
}
|
||||
numPendingCodeComments := int64(0)
|
||||
if currentReview != nil {
|
||||
numPendingCodeComments, err = issues_model.CountComments(ctx, &issues_model.FindCommentsOptions{
|
||||
Type: issues_model.CommentTypeCode,
|
||||
ReviewID: currentReview.ID,
|
||||
IssueID: issue.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("CountComments", err)
|
||||
var numPendingCodeComments int64
|
||||
var currentPendingReview *issues_model.Review
|
||||
if ctx.Doer != nil {
|
||||
currentPendingReview, err = issues_model.GetCurrentReview(ctx, ctx.Doer, issue)
|
||||
if err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
ctx.ServerError("GetCurrentReview", err)
|
||||
return
|
||||
}
|
||||
if currentPendingReview != nil {
|
||||
numPendingCodeComments, err = issues_model.CountComments(ctx, &issues_model.FindCommentsOptions{
|
||||
Type: issues_model.CommentTypeCode,
|
||||
ReviewID: currentPendingReview.ID,
|
||||
IssueID: issue.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("CountComments", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.Data["CurrentReview"] = currentReview
|
||||
ctx.Data["CurrentReview"] = currentPendingReview
|
||||
ctx.Data["PendingCodeCommentNumber"] = numPendingCodeComments
|
||||
|
||||
ctx.Data["IsIssuePoster"] = ctx.Doer != nil && issue.IsPoster(ctx.Doer.ID)
|
||||
|
||||
+1
-1
@@ -1662,7 +1662,7 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) {
|
||||
m.Get("/new_comment", repo.RenderNewCodeCommentForm)
|
||||
m.Post("/comments", web.Bind[*forms.CodeCommentForm](), repo.SetShowOutdatedComments, repo.CreateCodeComment)
|
||||
m.Post("/submit", web.Bind[*forms.SubmitReviewForm](), repo.SubmitReview)
|
||||
}, context.RepoMustNotBeArchived())
|
||||
}, reqSignIn, context.RepoMustNotBeArchived())
|
||||
})
|
||||
})
|
||||
}, optSignIn, context.RepoAssignment, repo.MustAllowPulls, reqUnitPullsReader)
|
||||
|
||||
Reference in new issue
Block a user