Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995)
(cherry picked from commit f8ab9dafb7a173a35e9308f8f784735b0f822439) Conflicts: routers/web/repo/fork.go trivial context conflict, the file does not exist in Forgejo
This commit is contained in:
parent
c97a7b8347
commit
196c8772a8
14 changed files with 41 additions and 77 deletions
|
@ -515,9 +515,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByCreatedDesc",
|
Name: "SortByCreatedDesc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByCreatedDesc,
|
SortBy: internal.SortByCreatedDesc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
@ -533,9 +531,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByUpdatedDesc",
|
Name: "SortByUpdatedDesc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByUpdatedDesc,
|
SortBy: internal.SortByUpdatedDesc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
@ -551,9 +547,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByCommentsDesc",
|
Name: "SortByCommentsDesc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByCommentsDesc,
|
SortBy: internal.SortByCommentsDesc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
@ -569,9 +563,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByDeadlineDesc",
|
Name: "SortByDeadlineDesc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByDeadlineDesc,
|
SortBy: internal.SortByDeadlineDesc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
@ -587,9 +579,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByCreatedAsc",
|
Name: "SortByCreatedAsc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByCreatedAsc,
|
SortBy: internal.SortByCreatedAsc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
@ -605,9 +595,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByUpdatedAsc",
|
Name: "SortByUpdatedAsc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByUpdatedAsc,
|
SortBy: internal.SortByUpdatedAsc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
@ -623,9 +611,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByCommentsAsc",
|
Name: "SortByCommentsAsc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByCommentsAsc,
|
SortBy: internal.SortByCommentsAsc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
@ -641,9 +627,7 @@ var cases = []*testIndexerCase{
|
||||||
{
|
{
|
||||||
Name: "SortByDeadlineAsc",
|
Name: "SortByDeadlineAsc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
SortBy: internal.SortByDeadlineAsc,
|
SortBy: internal.SortByDeadlineAsc,
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
|
|
@ -61,9 +61,7 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
reviews, err := issue_model.FindReviews(ctx, issue_model.FindReviewOptions{
|
reviews, err := issue_model.FindReviews(ctx, issue_model.FindReviewOptions{
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
IssueID: issueID,
|
IssueID: issueID,
|
||||||
OfficialOnly: false,
|
OfficialOnly: false,
|
||||||
})
|
})
|
||||||
|
|
|
@ -275,9 +275,7 @@ func ViewUser(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
repos, count, err := repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
|
repos, count, err := repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
OwnerID: u.ID,
|
OwnerID: u.ID,
|
||||||
OrderBy: db.SearchOrderByAlphabetically,
|
OrderBy: db.SearchOrderByAlphabetically,
|
||||||
Private: true,
|
Private: true,
|
||||||
|
@ -300,9 +298,7 @@ func ViewUser(ctx *context.Context) {
|
||||||
ctx.Data["EmailsTotal"] = len(emails)
|
ctx.Data["EmailsTotal"] = len(emails)
|
||||||
|
|
||||||
orgs, err := db.Find[org_model.Organization](ctx, org_model.FindOrgOptions{
|
orgs, err := db.Find[org_model.Organization](ctx, org_model.FindOrgOptions{
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
UserID: u.ID,
|
UserID: u.ID,
|
||||||
IncludePrivate: true,
|
IncludePrivate: true,
|
||||||
})
|
})
|
||||||
|
|
|
@ -367,7 +367,7 @@ func Diff(ctx *context.Context) {
|
||||||
ctx.Data["Commit"] = commit
|
ctx.Data["Commit"] = commit
|
||||||
ctx.Data["Diff"] = diff
|
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 {
|
if err != nil {
|
||||||
log.Error("GetLatestCommitStatus: %v", err)
|
log.Error("GetLatestCommitStatus: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,9 +698,7 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
|
||||||
|
|
||||||
branches, err = git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
|
branches, err = git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
|
||||||
RepoID: repo.ID,
|
RepoID: repo.ID,
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
IsDeletedBranch: optional.Some(false),
|
IsDeletedBranch: optional.Some(false),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -755,9 +753,7 @@ func CompareDiff(ctx *context.Context) {
|
||||||
|
|
||||||
headBranches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
|
headBranches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
|
||||||
RepoID: ci.HeadRepo.ID,
|
RepoID: ci.HeadRepo.ID,
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
IsDeletedBranch: optional.Some(false),
|
IsDeletedBranch: optional.Some(false),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -505,7 +505,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *issues_model.Issue)
|
||||||
|
|
||||||
if len(compareInfo.Commits) != 0 {
|
if len(compareInfo.Commits) != 0 {
|
||||||
sha := compareInfo.Commits[0].ID.String()
|
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 {
|
if err != nil {
|
||||||
ctx.ServerError("GetLatestCommitStatus", err)
|
ctx.ServerError("GetLatestCommitStatus", err)
|
||||||
return nil
|
return nil
|
||||||
|
@ -567,7 +567,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
|
||||||
ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err)
|
ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err)
|
||||||
return nil
|
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 {
|
if err != nil {
|
||||||
ctx.ServerError("GetLatestCommitStatus", err)
|
ctx.ServerError("GetLatestCommitStatus", err)
|
||||||
return nil
|
return nil
|
||||||
|
@ -659,7 +659,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
|
||||||
return nil
|
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 {
|
if err != nil {
|
||||||
ctx.ServerError("GetLatestCommitStatus", err)
|
ctx.ServerError("GetLatestCommitStatus", err)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -136,7 +136,7 @@ func getReleaseInfos(ctx *context.Context, opts *repo_model.FindReleasesOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
if canReadActions {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,9 +684,7 @@ func GetBranchesList(ctx *context.Context) {
|
||||||
branchOpts := git_model.FindBranchOptions{
|
branchOpts := git_model.FindBranchOptions{
|
||||||
RepoID: ctx.Repo.Repository.ID,
|
RepoID: ctx.Repo.Repository.ID,
|
||||||
IsDeletedBranch: optional.Some(false),
|
IsDeletedBranch: optional.Some(false),
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
branches, err := git_model.FindBranchNames(ctx, branchOpts)
|
branches, err := git_model.FindBranchNames(ctx, branchOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -719,9 +717,7 @@ func PrepareBranchList(ctx *context.Context) {
|
||||||
branchOpts := git_model.FindBranchOptions{
|
branchOpts := git_model.FindBranchOptions{
|
||||||
RepoID: ctx.Repo.Repository.ID,
|
RepoID: ctx.Repo.Repository.ID,
|
||||||
IsDeletedBranch: optional.Some(false),
|
IsDeletedBranch: optional.Some(false),
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
brs, err := git_model.FindBranchNames(ctx, branchOpts)
|
brs, err := git_model.FindBranchNames(ctx, branchOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -364,7 +364,7 @@ func loadLatestCommitData(ctx *context.Context, latestCommit *git.Commit) bool {
|
||||||
ctx.Data["LatestCommitVerification"] = verification
|
ctx.Data["LatestCommitVerification"] = verification
|
||||||
ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(ctx, latestCommit)
|
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 {
|
if err != nil {
|
||||||
log.Error("GetLatestCommitStatus: %v", err)
|
log.Error("GetLatestCommitStatus: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ func createCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) er
|
||||||
}
|
}
|
||||||
ctxname := fmt.Sprintf("%s / %s (%s)", runName, job.Name, event)
|
ctxname := fmt.Sprintf("%s / %s (%s)", runName, job.Name, event)
|
||||||
state := toCommitStatus(job.Status)
|
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 {
|
for _, v := range statuses {
|
||||||
if v.Context == ctxname {
|
if v.Context == ctxname {
|
||||||
if v.State == state {
|
if v.State == state {
|
||||||
|
|
|
@ -153,7 +153,7 @@ func GetPullRequestCommitStatusState(ctx context.Context, pr *issues_model.PullR
|
||||||
return "", fmt.Errorf("LoadBaseRepo: %w", err)
|
return "", fmt.Errorf("LoadBaseRepo: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
if err != nil {
|
||||||
return "", fmt.Errorf("GetLatestCommitStatus: %w", err)
|
return "", fmt.Errorf("GetLatestCommitStatus: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -893,7 +893,7 @@ func getAllCommitStatus(ctx context.Context, gitRepo *git.Repository, pr *issues
|
||||||
return nil, nil, shaErr
|
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)
|
lastStatus = git_model.CalcCommitStatus(statuses)
|
||||||
return statuses, lastStatus, err
|
return statuses, lastStatus, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,7 @@ func InvalidateCodeComments(ctx context.Context, prs issues_model.PullRequestLis
|
||||||
issueIDs := prs.GetIssueIDs()
|
issueIDs := prs.GetIssueIDs()
|
||||||
|
|
||||||
codeComments, err := db.Find[issues_model.Comment](ctx, issues_model.FindCommentsOptions{
|
codeComments, err := db.Find[issues_model.Comment](ctx, issues_model.FindCommentsOptions{
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
Type: issues_model.CommentTypeCode,
|
Type: issues_model.CommentTypeCode,
|
||||||
Invalidated: optional.Some(false),
|
Invalidated: optional.Some(false),
|
||||||
IssueIDs: issueIDs,
|
IssueIDs: issueIDs,
|
||||||
|
@ -322,9 +320,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
|
||||||
// DismissApprovalReviews dismiss all approval reviews because of new commits
|
// DismissApprovalReviews dismiss all approval reviews because of new commits
|
||||||
func DismissApprovalReviews(ctx context.Context, doer *user_model.User, pull *issues_model.PullRequest) error {
|
func DismissApprovalReviews(ctx context.Context, doer *user_model.User, pull *issues_model.PullRequest) error {
|
||||||
reviews, err := issues_model.FindReviews(ctx, issues_model.FindReviewOptions{
|
reviews, err := issues_model.FindReviews(ctx, issues_model.FindReviewOptions{
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
IssueID: pull.IssueID,
|
IssueID: pull.IssueID,
|
||||||
Type: issues_model.ReviewTypeApprove,
|
Type: issues_model.ReviewTypeApprove,
|
||||||
Dismissed: optional.Some(false),
|
Dismissed: optional.Some(false),
|
||||||
|
|
|
@ -145,9 +145,7 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r
|
||||||
|
|
||||||
branches, _ := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
|
branches, _ := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
|
||||||
RepoID: repo.ID,
|
RepoID: repo.ID,
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptionsAll,
|
||||||
ListAll: true,
|
|
||||||
},
|
|
||||||
IsDeletedBranch: optional.Some(false),
|
IsDeletedBranch: optional.Some(false),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue