aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-03-22 20:53:52 +0800
committerGitHub <noreply@github.com>2024-03-22 13:53:52 +0100
commitf8ab9dafb7a173a35e9308f8f784735b0f822439 (patch)
tree407c8062fd1943eac09af96b54c8521445c3e48c
parent29118743a58cf3172bddb6a4fa287484c62b4eb1 (diff)
downloadgitea-f8ab9dafb7a173a35e9308f8f784735b0f822439.tar.gz
gitea-f8ab9dafb7a173a35e9308f8f784735b0f822439.zip
Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995)
-rw-r--r--modules/indexer/issues/internal/tests/tests.go48
-rw-r--r--modules/indexer/issues/util.go4
-rw-r--r--routers/web/admin/users.go8
-rw-r--r--routers/web/repo/commit.go2
-rw-r--r--routers/web/repo/compare.go12
-rw-r--r--routers/web/repo/fork.go6
-rw-r--r--routers/web/repo/pull.go6
-rw-r--r--routers/web/repo/release.go2
-rw-r--r--routers/web/repo/repo.go8
-rw-r--r--routers/web/repo/view.go2
-rw-r--r--services/actions/commit_status.go2
-rw-r--r--services/pull/commit_status.go2
-rw-r--r--services/pull/pull.go2
-rw-r--r--services/pull/review.go14
-rw-r--r--services/repository/adopt.go6
15 files changed, 43 insertions, 81 deletions
diff --git a/modules/indexer/issues/internal/tests/tests.go b/modules/indexer/issues/internal/tests/tests.go
index 91aafd589c..2209377c2f 100644
--- a/modules/indexer/issues/internal/tests/tests.go
+++ b/modules/indexer/issues/internal/tests/tests.go
@@ -515,10 +515,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByCreatedDesc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByCreatedDesc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByCreatedDesc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
@@ -533,10 +531,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByUpdatedDesc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByUpdatedDesc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByUpdatedDesc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
@@ -551,10 +547,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByCommentsDesc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByCommentsDesc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByCommentsDesc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
@@ -569,10 +563,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByDeadlineDesc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByDeadlineDesc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByDeadlineDesc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
@@ -587,10 +579,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByCreatedAsc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByCreatedAsc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByCreatedAsc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
@@ -605,10 +595,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByUpdatedAsc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByUpdatedAsc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByUpdatedAsc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
@@ -623,10 +611,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByCommentsAsc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByCommentsAsc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByCommentsAsc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
@@ -641,10 +627,8 @@ var cases = []*testIndexerCase{
{
Name: "SortByDeadlineAsc",
SearchOptions: &internal.SearchOptions{
- Paginator: &db.ListOptions{
- ListAll: true,
- },
- SortBy: internal.SortByDeadlineAsc,
+ Paginator: &db.ListOptionsAll,
+ SortBy: internal.SortByDeadlineAsc,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, len(data), len(result.Hits))
diff --git a/modules/indexer/issues/util.go b/modules/indexer/issues/util.go
index 510b4060b2..9861c808dc 100644
--- a/modules/indexer/issues/util.go
+++ b/modules/indexer/issues/util.go
@@ -61,9 +61,7 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD
)
{
reviews, err := issue_model.FindReviews(ctx, issue_model.FindReviewOptions{
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ ListOptions: db.ListOptionsAll,
IssueID: issueID,
OfficialOnly: false,
})
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index 6dfcfc3d9a..b93668c5a2 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -275,9 +275,7 @@ func ViewUser(ctx *context.Context) {
}
repos, count, err := repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ ListOptions: db.ListOptionsAll,
OwnerID: u.ID,
OrderBy: db.SearchOrderByAlphabetically,
Private: true,
@@ -300,9 +298,7 @@ func ViewUser(ctx *context.Context) {
ctx.Data["EmailsTotal"] = len(emails)
orgs, err := db.Find[org_model.Organization](ctx, org_model.FindOrgOptions{
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ ListOptions: db.ListOptionsAll,
UserID: u.ID,
IncludePrivate: true,
})
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index d66de782f4..8543fa44cc 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -351,7 +351,7 @@ func Diff(ctx *context.Context) {
ctx.Data["Commit"] = commit
ctx.Data["Diff"] = diff
- statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptions{ListAll: true})
+ statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptionsAll)
if err != nil {
log.Error("GetLatestCommitStatus: %v", err)
}
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index 7b5243e6b7..cfb0e859bd 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -697,10 +697,8 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
defer gitRepo.Close()
branches, err = git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
- RepoID: repo.ID,
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ RepoID: repo.ID,
+ ListOptions: db.ListOptionsAll,
IsDeletedBranch: optional.Some(false),
})
if err != nil {
@@ -754,10 +752,8 @@ func CompareDiff(ctx *context.Context) {
}
headBranches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
- RepoID: ci.HeadRepo.ID,
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ RepoID: ci.HeadRepo.ID,
+ ListOptions: db.ListOptionsAll,
IsDeletedBranch: optional.Some(false),
})
if err != nil {
diff --git a/routers/web/repo/fork.go b/routers/web/repo/fork.go
index 60e37476ee..27e42a8f98 100644
--- a/routers/web/repo/fork.go
+++ b/routers/web/repo/fork.go
@@ -101,10 +101,8 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
}
branches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
- RepoID: ctx.Repo.Repository.ID,
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ RepoID: ctx.Repo.Repository.ID,
+ ListOptions: db.ListOptionsAll,
IsDeletedBranch: optional.Some(false),
// Add it as the first option
ExcludeBranchNames: []string{ctx.Repo.Repository.DefaultBranch},
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index 447781602d..2422be39b8 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -278,7 +278,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *issues_model.Issue)
if len(compareInfo.Commits) != 0 {
sha := compareInfo.Commits[0].ID.String()
- commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{ListAll: true})
+ commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptionsAll)
if err != nil {
ctx.ServerError("GetLatestCommitStatus", err)
return nil
@@ -340,7 +340,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err)
return nil
}
- commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
+ commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll)
if err != nil {
ctx.ServerError("GetLatestCommitStatus", err)
return nil
@@ -432,7 +432,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
return nil
}
- commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
+ commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll)
if err != nil {
ctx.ServerError("GetLatestCommitStatus", err)
return nil
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index dbc190928f..7ba23f0701 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -136,7 +136,7 @@ func getReleaseInfos(ctx *context.Context, opts *repo_model.FindReleasesOptions)
}
if canReadActions {
- statuses, _, err := git_model.GetLatestCommitStatus(ctx, r.Repo.ID, r.Sha1, db.ListOptions{ListAll: true})
+ statuses, _, err := git_model.GetLatestCommitStatus(ctx, r.Repo.ID, r.Sha1, db.ListOptionsAll)
if err != nil {
return nil, err
}
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 0490feb621..4e448933c7 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -688,9 +688,7 @@ func GetBranchesList(ctx *context.Context) {
branchOpts := git_model.FindBranchOptions{
RepoID: ctx.Repo.Repository.ID,
IsDeletedBranch: optional.Some(false),
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ ListOptions: db.ListOptionsAll,
}
branches, err := git_model.FindBranchNames(ctx, branchOpts)
if err != nil {
@@ -723,9 +721,7 @@ func PrepareBranchList(ctx *context.Context) {
branchOpts := git_model.FindBranchOptions{
RepoID: ctx.Repo.Repository.ID,
IsDeletedBranch: optional.Some(false),
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ ListOptions: db.ListOptionsAll,
}
brs, err := git_model.FindBranchNames(ctx, branchOpts)
if err != nil {
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 712d12705e..b9e623919a 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -359,7 +359,7 @@ func loadLatestCommitData(ctx *context.Context, latestCommit *git.Commit) bool {
ctx.Data["LatestCommitVerification"] = verification
ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(ctx, latestCommit)
- statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{ListAll: true})
+ statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptionsAll)
if err != nil {
log.Error("GetLatestCommitStatus: %v", err)
}
diff --git a/services/actions/commit_status.go b/services/actions/commit_status.go
index edd1fd1568..4236553927 100644
--- a/services/actions/commit_status.go
+++ b/services/actions/commit_status.go
@@ -79,7 +79,7 @@ func createCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) er
}
ctxname := fmt.Sprintf("%s / %s (%s)", runName, job.Name, event)
state := toCommitStatus(job.Status)
- if statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}); err == nil {
+ if statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll); err == nil {
for _, v := range statuses {
if v.Context == ctxname {
if v.State == state {
diff --git a/services/pull/commit_status.go b/services/pull/commit_status.go
index 653bfe6bcb..aa1ad7cd66 100644
--- a/services/pull/commit_status.go
+++ b/services/pull/commit_status.go
@@ -152,7 +152,7 @@ func GetPullRequestCommitStatusState(ctx context.Context, pr *issues_model.PullR
return "", errors.Wrap(err, "LoadBaseRepo")
}
- commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true})
+ commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptionsAll)
if err != nil {
return "", errors.Wrap(err, "GetLatestCommitStatus")
}
diff --git a/services/pull/pull.go b/services/pull/pull.go
index 8a9c6db917..4289e2e6e1 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -883,7 +883,7 @@ func getAllCommitStatus(ctx context.Context, gitRepo *git.Repository, pr *issues
return nil, nil, shaErr
}
- statuses, _, err = git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true})
+ statuses, _, err = git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptionsAll)
lastStatus = git_model.CalcCommitStatus(statuses)
return statuses, lastStatus, err
}
diff --git a/services/pull/review.go b/services/pull/review.go
index 8900ae2ab1..de1021c5c0 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -52,9 +52,7 @@ func InvalidateCodeComments(ctx context.Context, prs issues_model.PullRequestLis
issueIDs := prs.GetIssueIDs()
codeComments, err := db.Find[issues_model.Comment](ctx, issues_model.FindCommentsOptions{
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ ListOptions: db.ListOptionsAll,
Type: issues_model.CommentTypeCode,
Invalidated: optional.Some(false),
IssueIDs: issueIDs,
@@ -322,12 +320,10 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
// DismissApprovalReviews dismiss all approval reviews because of new commits
func DismissApprovalReviews(ctx context.Context, doer *user_model.User, pull *issues_model.PullRequest) error {
reviews, err := issues_model.FindReviews(ctx, issues_model.FindReviewOptions{
- ListOptions: db.ListOptions{
- ListAll: true,
- },
- IssueID: pull.IssueID,
- Type: issues_model.ReviewTypeApprove,
- Dismissed: optional.Some(false),
+ ListOptions: db.ListOptionsAll,
+ IssueID: pull.IssueID,
+ Type: issues_model.ReviewTypeApprove,
+ Dismissed: optional.Some(false),
})
if err != nil {
return err
diff --git a/services/repository/adopt.go b/services/repository/adopt.go
index 0ac3c774b7..b337eac38a 100644
--- a/services/repository/adopt.go
+++ b/services/repository/adopt.go
@@ -144,10 +144,8 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r
}
branches, _ := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
- RepoID: repo.ID,
- ListOptions: db.ListOptions{
- ListAll: true,
- },
+ RepoID: repo.ID,
+ ListOptions: db.ListOptionsAll,
IsDeletedBranch: optional.Some(false),
})