From f00e0a6f72316636e05feed10ac0debfda696d7b Mon Sep 17 00:00:00 2001 From: CaiCandong <1290147055@qq.com> Date: Thu, 27 Jul 2023 14:04:47 +0800 Subject: [PATCH] fix Pull request check list is limited --- models/git/commit_status.go | 6 +++--- routers/web/repo/commit.go | 2 +- routers/web/repo/pull.go | 6 +++--- routers/web/repo/view.go | 2 +- services/actions/commit_status.go | 2 +- services/pull/commit_status.go | 2 +- services/pull/pull.go | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/models/git/commit_status.go b/models/git/commit_status.go index 17090f30dd55b..e7616fb167392 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -283,9 +283,9 @@ func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOp Where("repo_id = ?", repoID).And("sha = ?", sha). Select("max( id ) as id"). GroupBy("context_hash").OrderBy("max( id ) desc") - - sess = db.SetSessionPagination(sess, &listOptions) - + if !listOptions.IsListAll() { + sess = db.SetSessionPagination(sess, &listOptions) + } count, err := sess.FindAndCount(&ids) if err != nil { return nil, count, err diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index e88f1139f8b7e..8fad423323906 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -339,7 +339,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{}) + statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptions{ListAll: true}) if err != nil { log.Error("GetLatestCommitStatus: %v", err) } diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 237e53413f767..cc0153c4dea47 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -469,7 +469,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{}) + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{ListAll: true}) if err != nil { ctx.ServerError("GetLatestCommitStatus", err) return nil @@ -531,7 +531,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{}) + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}) if err != nil { ctx.ServerError("GetLatestCommitStatus", err) return nil @@ -623,7 +623,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{}) + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}) if err != nil { ctx.ServerError("GetLatestCommitStatus", err) return nil diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 221c1f4c4f62b..ae22bae9c1aa7 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -842,7 +842,7 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri 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{}) + statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{ListAll: true}) if err != nil { log.Error("GetLatestCommitStatus: %v", err) } diff --git a/services/actions/commit_status.go b/services/actions/commit_status.go index 925d0a33968aa..08a7dde67c85b 100644 --- a/services/actions/commit_status.go +++ b/services/actions/commit_status.go @@ -75,7 +75,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{}); err == nil { + if statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}); 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 51ba06da27586..39d60380ff202 100644 --- a/services/pull/commit_status.go +++ b/services/pull/commit_status.go @@ -143,7 +143,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{}) + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true}) if err != nil { return "", errors.Wrap(err, "GetLatestCommitStatus") } diff --git a/services/pull/pull.go b/services/pull/pull.go index 3c6caec8825a8..bc12e82e68f1a 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -801,7 +801,7 @@ func getAllCommitStatus(gitRepo *git.Repository, pr *issues_model.PullRequest) ( return nil, nil, shaErr } - statuses, _, err = git_model.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{}) + statuses, _, err = git_model.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true}) lastStatus = git_model.CalcCommitStatus(statuses) return statuses, lastStatus, err }