Skip to content

Commit 0600269

Browse files
GiteaBotCaiCandong
andauthored
Fix pull request check list is limited (#26179) (#26245)
Backport #26179 by @CaiCandong In the original implementation, we can only get the first 30 records of the commit status (the default paging size), if the commit status is more than 30, it will lead to the bug #25990. I made the following two changes. - On the page, use the ` db.ListOptions{ListAll: true}` parameter instead of `db.ListOptions{}` - The `GetLatestCommitStatus` function makes a determination as to whether or not a pager is being used. fixed #25990 Co-authored-by: caicandong <50507092+CaiCandong@users.noreply.github.com>
1 parent 0f265a2 commit 0600269

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

models/git/commit_status.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOp
283283
Where("repo_id = ?", repoID).And("sha = ?", sha).
284284
Select("max( id ) as id").
285285
GroupBy("context_hash").OrderBy("max( id ) desc")
286-
287-
sess = db.SetSessionPagination(sess, &listOptions)
288-
286+
if !listOptions.IsListAll() {
287+
sess = db.SetSessionPagination(sess, &listOptions)
288+
}
289289
count, err := sess.FindAndCount(&ids)
290290
if err != nil {
291291
return nil, count, err

routers/web/repo/commit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func Diff(ctx *context.Context) {
339339
ctx.Data["Commit"] = commit
340340
ctx.Data["Diff"] = diff
341341

342-
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptions{})
342+
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptions{ListAll: true})
343343
if err != nil {
344344
log.Error("GetLatestCommitStatus: %v", err)
345345
}

routers/web/repo/pull.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *issues_model.Issue)
421421

422422
if len(compareInfo.Commits) != 0 {
423423
sha := compareInfo.Commits[0].ID.String()
424-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{})
424+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{ListAll: true})
425425
if err != nil {
426426
ctx.ServerError("GetLatestCommitStatus", err)
427427
return nil
@@ -483,7 +483,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
483483
ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err)
484484
return nil
485485
}
486-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{})
486+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
487487
if err != nil {
488488
ctx.ServerError("GetLatestCommitStatus", err)
489489
return nil
@@ -575,7 +575,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
575575
return nil
576576
}
577577

578-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{})
578+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
579579
if err != nil {
580580
ctx.ServerError("GetLatestCommitStatus", err)
581581
return nil

routers/web/repo/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri
834834
ctx.Data["LatestCommitVerification"] = verification
835835
ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(ctx, latestCommit)
836836

837-
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{})
837+
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{ListAll: true})
838838
if err != nil {
839839
log.Error("GetLatestCommitStatus: %v", err)
840840
}

services/actions/commit_status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func createCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) er
7575
}
7676
ctxname := fmt.Sprintf("%s / %s (%s)", runName, job.Name, event)
7777
state := toCommitStatus(job.Status)
78-
if statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{}); err == nil {
78+
if statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}); err == nil {
7979
for _, v := range statuses {
8080
if v.Context == ctxname {
8181
if v.State == state {

services/pull/commit_status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func GetPullRequestCommitStatusState(ctx context.Context, pr *issues_model.PullR
143143
return "", errors.Wrap(err, "LoadBaseRepo")
144144
}
145145

146-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{})
146+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true})
147147
if err != nil {
148148
return "", errors.Wrap(err, "GetLatestCommitStatus")
149149
}

services/pull/pull.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ func getAllCommitStatus(gitRepo *git.Repository, pr *issues_model.PullRequest) (
794794
return nil, nil, shaErr
795795
}
796796

797-
statuses, _, err = git_model.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{})
797+
statuses, _, err = git_model.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true})
798798
lastStatus = git_model.CalcCommitStatus(statuses)
799799
return statuses, lastStatus, err
800800
}

0 commit comments

Comments
 (0)