Skip to content

Commit 983167c

Browse files
authored
Fix pull request check list is limited (#26179)
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
1 parent ea385f5 commit 983167c

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
@@ -349,7 +349,7 @@ func Diff(ctx *context.Context) {
349349
ctx.Data["Commit"] = commit
350350
ctx.Data["Diff"] = diff
351351

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

routers/web/repo/pull.go

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

470470
if len(compareInfo.Commits) != 0 {
471471
sha := compareInfo.Commits[0].ID.String()
472-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{})
472+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{ListAll: true})
473473
if err != nil {
474474
ctx.ServerError("GetLatestCommitStatus", err)
475475
return nil
@@ -531,7 +531,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
531531
ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err)
532532
return nil
533533
}
534-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{})
534+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
535535
if err != nil {
536536
ctx.ServerError("GetLatestCommitStatus", err)
537537
return nil
@@ -623,7 +623,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
623623
return nil
624624
}
625625

626-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{})
626+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
627627
if err != nil {
628628
ctx.ServerError("GetLatestCommitStatus", err)
629629
return nil

routers/web/repo/view.go

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

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

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
@@ -804,7 +804,7 @@ func getAllCommitStatus(gitRepo *git.Repository, pr *issues_model.PullRequest) (
804804
return nil, nil, shaErr
805805
}
806806

807-
statuses, _, err = git_model.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{})
807+
statuses, _, err = git_model.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true})
808808
lastStatus = git_model.CalcCommitStatus(statuses)
809809
return statuses, lastStatus, err
810810
}

0 commit comments

Comments
 (0)