0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-15 14:31:41 +01:00

Dont load Review if Comment is CommentTypeReviewRequest (#28551) (#29160)

Backport #28551

RequestReview get deleted on review.
So we don't have to try to load them on comments.
This commit is contained in:
6543 2024-02-13 23:29:33 +01:00 committed by GitHub
parent 732d511e04
commit 0ac3186267
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -688,8 +688,15 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository
} }
func (c *Comment) loadReview(ctx context.Context) (err error) { func (c *Comment) loadReview(ctx context.Context) (err error) {
if c.ReviewID == 0 {
return nil
}
if c.Review == nil { if c.Review == nil {
if c.Review, err = GetReviewByID(ctx, c.ReviewID); err != nil { if c.Review, err = GetReviewByID(ctx, c.ReviewID); err != nil {
// review request which has been replaced by actual reviews doesn't exist in database anymore, so ignorem them.
if c.Type == CommentTypeReviewRequest {
return nil
}
return err return err
} }
} }

View file

@ -430,7 +430,8 @@ func (comments CommentList) loadReviews(ctx context.Context) error {
for _, comment := range comments { for _, comment := range comments {
comment.Review = reviews[comment.ReviewID] comment.Review = reviews[comment.ReviewID]
if comment.Review == nil { if comment.Review == nil {
if comment.ReviewID > 0 { // review request which has been replaced by actual reviews doesn't exist in database anymore, so don't log errors for them.
if comment.ReviewID > 0 && comment.Type != CommentTypeReviewRequest {
log.Error("comment with review id [%d] but has no review record", comment.ReviewID) log.Error("comment with review id [%d] but has no review record", comment.ReviewID)
} }
continue continue

View file

@ -622,6 +622,9 @@ func AddReviewRequest(ctx context.Context, issue *Issue, reviewer, doer *user_mo
return nil, err return nil, err
} }
// func caller use the created comment to retrieve created review too.
comment.Review = review
return comment, committer.Commit() return comment, committer.Commit()
} }