aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues
diff options
context:
space:
mode:
authorZettat123 <zettat123@gmail.com>2024-10-01 09:58:55 +0800
committerGitHub <noreply@github.com>2024-10-01 01:58:55 +0000
commitf4b8f6fc40ce2869135372a5c6ec6418d27ebfba (patch)
treeb27dca5e2fe9b455dfa20e2080a8c77b3f90c000 /models/issues
parent13283873e9d523d5a5557f55d64f702c1a9f76ec (diff)
downloadgitea-f4b8f6fc40ce2869135372a5c6ec6418d27ebfba.tar.gz
gitea-f4b8f6fc40ce2869135372a5c6ec6418d27ebfba.zip
Fix the logic of finding the latest pull review commit ID (#32139)
Fix #31423
Diffstat (limited to 'models/issues')
-rw-r--r--models/issues/pull.go2
-rw-r--r--models/issues/review.go2
-rw-r--r--models/issues/review_list.go6
-rw-r--r--models/issues/review_test.go4
4 files changed, 7 insertions, 7 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go
index 4a5782f836..b327ebc625 100644
--- a/models/issues/pull.go
+++ b/models/issues/pull.go
@@ -414,7 +414,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 9fb6d7573a..8b345e5fd8 100644
--- a/models/issues/review.go
+++ b/models/issues/review.go
@@ -389,7 +389,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 ac1b84adeb..942121fd8f 100644
--- a/models/issues/review_test.go
+++ b/models/issues/review_test.go
@@ -63,7 +63,7 @@ func TestReviewType_Icon(t *testing.T) {
func TestFindReviews(t *testing.T) {
assert.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,
})
@@ -75,7 +75,7 @@ func TestFindReviews(t *testing.T) {
func TestFindLatestReviews(t *testing.T) {
assert.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,
})
assert.NoError(t, err)