소스 검색

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.
tags/v1.21.6
6543 3 달 전
부모
커밋
0ac3186267
No account linked to committer's email address
3개의 변경된 파일12개의 추가작업 그리고 1개의 파일을 삭제
  1. 7
    0
      models/issues/comment.go
  2. 2
    1
      models/issues/comment_list.go
  3. 3
    0
      models/issues/review.go

+ 7
- 0
models/issues/comment.go 파일 보기

@@ -688,8 +688,15 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository
}

func (c *Comment) loadReview(ctx context.Context) (err error) {
if c.ReviewID == 0 {
return nil
}
if c.Review == 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
}
}

+ 2
- 1
models/issues/comment_list.go 파일 보기

@@ -430,7 +430,8 @@ func (comments CommentList) loadReviews(ctx context.Context) error {
for _, comment := range comments {
comment.Review = reviews[comment.ReviewID]
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)
}
continue

+ 3
- 0
models/issues/review.go 파일 보기

@@ -622,6 +622,9 @@ func AddReviewRequest(ctx context.Context, issue *Issue, reviewer, doer *user_mo
return nil, err
}

// func caller use the created comment to retrieve created review too.
comment.Review = review

return comment, committer.Commit()
}


Loading…
취소
저장