diff options
author | Earl Warren <earl-warren@noreply.codeberg.org> | 2024-10-09 07:02:20 +0200 |
---|---|---|
committer | Earl Warren <earl-warren@noreply.codeberg.org> | 2024-10-09 07:02:20 +0200 |
commit | 31fc0f66b73b201a88b86bbd0c366feb0a5c9396 (patch) | |
tree | 6c187efe16be1e35f32fde393dc6a4ee265610f1 /models/issues | |
parent | [Feat]Add link to show all Issues/PullRequests (#4125) (diff) | |
parent | Fix the logic of finding the latest pull review commit ID (#32139) (followup) (diff) | |
download | forgejo-31fc0f66b73b201a88b86bbd0c366feb0a5c9396.tar.xz forgejo-31fc0f66b73b201a88b86bbd0c366feb0a5c9396.zip |
Merge pull request '[gitea] week 2024-41 cherry pick (gitea/main -> forgejo)' (#5477) from earl-warren/wcp/2024-41 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5477
Reviewed-by: Otto <otto@codeberg.org>
Diffstat (limited to 'models/issues')
-rw-r--r-- | models/issues/pull.go | 2 | ||||
-rw-r--r-- | models/issues/review.go | 2 | ||||
-rw-r--r-- | models/issues/review_list.go | 6 | ||||
-rw-r--r-- | models/issues/review_test.go | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go index a035cad649..45e2e19434 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -408,7 +408,7 @@ func (pr *PullRequest) getReviewedByLines(ctx context.Context, writer io.Writer) // Note: This doesn't page as we only expect a very limited number of reviews reviews, err := FindLatestReviews(ctx, FindReviewOptions{ - Type: ReviewTypeApprove, + Types: []ReviewType{ReviewTypeApprove}, IssueID: pr.IssueID, OfficialOnly: setting.Repository.PullRequest.DefaultMergeMessageOfficialApproversOnly, }) diff --git a/models/issues/review.go b/models/issues/review.go index ca6fd6035b..a39c12069b 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -364,7 +364,7 @@ func GetCurrentReview(ctx context.Context, reviewer *user_model.User, issue *Iss return nil, nil } reviews, err := FindReviews(ctx, FindReviewOptions{ - Type: ReviewTypePending, + Types: []ReviewType{ReviewTypePending}, IssueID: issue.ID, ReviewerID: reviewer.ID, }) diff --git a/models/issues/review_list.go b/models/issues/review_list.go index 0ee28874ec..a5ceb21791 100644 --- a/models/issues/review_list.go +++ b/models/issues/review_list.go @@ -92,7 +92,7 @@ func (reviews ReviewList) LoadIssues(ctx context.Context) error { // FindReviewOptions represent possible filters to find reviews type FindReviewOptions struct { db.ListOptions - Type ReviewType + Types []ReviewType IssueID int64 ReviewerID int64 OfficialOnly bool @@ -107,8 +107,8 @@ func (opts *FindReviewOptions) toCond() builder.Cond { if opts.ReviewerID > 0 { cond = cond.And(builder.Eq{"reviewer_id": opts.ReviewerID}) } - if opts.Type != ReviewTypeUnknown { - cond = cond.And(builder.Eq{"type": opts.Type}) + if len(opts.Types) > 0 { + cond = cond.And(builder.In("type", opts.Types)) } if opts.OfficialOnly { cond = cond.And(builder.Eq{"official": true}) diff --git a/models/issues/review_test.go b/models/issues/review_test.go index 43dc9ed2c1..51cb940579 100644 --- a/models/issues/review_test.go +++ b/models/issues/review_test.go @@ -64,7 +64,7 @@ func TestReviewType_Icon(t *testing.T) { func TestFindReviews(t *testing.T) { require.NoError(t, unittest.PrepareTestDatabase()) reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{ - Type: issues_model.ReviewTypeApprove, + Types: []issues_model.ReviewType{issues_model.ReviewTypeApprove}, IssueID: 2, ReviewerID: 1, }) @@ -76,7 +76,7 @@ func TestFindReviews(t *testing.T) { func TestFindLatestReviews(t *testing.T) { require.NoError(t, unittest.PrepareTestDatabase()) reviews, err := issues_model.FindLatestReviews(db.DefaultContext, issues_model.FindReviewOptions{ - Type: issues_model.ReviewTypeApprove, + Types: []issues_model.ReviewType{issues_model.ReviewTypeApprove}, IssueID: 11, }) require.NoError(t, err) |