{ | { | ||||
Name: "SortByCreatedDesc", | Name: "SortByCreatedDesc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) | ||||
{ | { | ||||
Name: "SortByUpdatedDesc", | Name: "SortByUpdatedDesc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) | ||||
{ | { | ||||
Name: "SortByCommentsDesc", | Name: "SortByCommentsDesc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) | ||||
{ | { | ||||
Name: "SortByDeadlineDesc", | Name: "SortByDeadlineDesc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) | ||||
{ | { | ||||
Name: "SortByCreatedAsc", | Name: "SortByCreatedAsc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) | ||||
{ | { | ||||
Name: "SortByUpdatedAsc", | Name: "SortByUpdatedAsc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) | ||||
{ | { | ||||
Name: "SortByCommentsAsc", | Name: "SortByCommentsAsc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) | ||||
{ | { | ||||
Name: "SortByDeadlineAsc", | Name: "SortByDeadlineAsc", | ||||
SearchOptions: &internal.SearchOptions{ | 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) { | Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { | ||||
assert.Equal(t, len(data), len(result.Hits)) | assert.Equal(t, len(data), len(result.Hits)) |
) | ) | ||||
{ | { | ||||
reviews, err := issue_model.FindReviews(ctx, issue_model.FindReviewOptions{ | reviews, err := issue_model.FindReviews(ctx, issue_model.FindReviewOptions{ | ||||
ListOptions: db.ListOptions{ | |||||
ListAll: true, | |||||
}, | |||||
ListOptions: db.ListOptionsAll, | |||||
IssueID: issueID, | IssueID: issueID, | ||||
OfficialOnly: false, | OfficialOnly: false, | ||||
}) | }) |
} | } | ||||
repos, count, err := repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{ | repos, count, err := repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{ | ||||
ListOptions: db.ListOptions{ | |||||
ListAll: true, | |||||
}, | |||||
ListOptions: db.ListOptionsAll, | |||||
OwnerID: u.ID, | OwnerID: u.ID, | ||||
OrderBy: db.SearchOrderByAlphabetically, | OrderBy: db.SearchOrderByAlphabetically, | ||||
Private: true, | Private: true, | ||||
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{ | |||||
ListAll: true, | |||||
}, | |||||
ListOptions: db.ListOptionsAll, | |||||
UserID: u.ID, | UserID: u.ID, | ||||
IncludePrivate: true, | IncludePrivate: true, | ||||
}) | }) |
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) | ||||
} | } |
defer gitRepo.Close() | defer gitRepo.Close() | ||||
branches, err = git_model.FindBranchNames(ctx, git_model.FindBranchOptions{ | 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), | IsDeletedBranch: optional.Some(false), | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
} | } | ||||
headBranches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{ | 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), | IsDeletedBranch: optional.Some(false), | ||||
}) | }) | ||||
if err != nil { | if err != nil { |
} | } | ||||
branches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{ | 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), | IsDeletedBranch: optional.Some(false), | ||||
// Add it as the first option | // Add it as the first option | ||||
ExcludeBranchNames: []string{ctx.Repo.Repository.DefaultBranch}, | ExcludeBranchNames: []string{ctx.Repo.Repository.DefaultBranch}, |
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 | ||||
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 | ||||
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 |
} | } | ||||
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 | ||||
} | } |
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{ | |||||
ListAll: true, | |||||
}, | |||||
ListOptions: db.ListOptionsAll, | |||||
} | } | ||||
branches, err := git_model.FindBranchNames(ctx, branchOpts) | branches, err := git_model.FindBranchNames(ctx, branchOpts) | ||||
if err != nil { | if err != nil { | ||||
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{ | |||||
ListAll: true, | |||||
}, | |||||
ListOptions: db.ListOptionsAll, | |||||
} | } | ||||
brs, err := git_model.FindBranchNames(ctx, branchOpts) | brs, err := git_model.FindBranchNames(ctx, branchOpts) | ||||
if err != nil { | if err != nil { |
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) | ||||
} | } |
} | } | ||||
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 { |
return "", errors.Wrap(err, "LoadBaseRepo") | 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 { | if err != nil { | ||||
return "", errors.Wrap(err, "GetLatestCommitStatus") | return "", errors.Wrap(err, "GetLatestCommitStatus") | ||||
} | } |
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 | ||||
} | } |
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{ | |||||
ListAll: true, | |||||
}, | |||||
ListOptions: db.ListOptionsAll, | |||||
Type: issues_model.CommentTypeCode, | Type: issues_model.CommentTypeCode, | ||||
Invalidated: optional.Some(false), | Invalidated: optional.Some(false), | ||||
IssueIDs: issueIDs, | IssueIDs: issueIDs, | ||||
// 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{ | |||||
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 { | if err != nil { | ||||
return err | return err |
} | } | ||||
branches, _ := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{ | 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), | IsDeletedBranch: optional.Some(false), | ||||
}) | }) | ||||