diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index c5302dd50f..9f71ab4632 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -581,7 +581,7 @@ func GetPullCommits(ctx *context.Context) { } resp := &pullCommitList{} - commits, lastReviewCommitSha, err := pull_service.GetPullCommits(ctx, issue) + commits, lastReviewCommitSha, err := pull_service.GetPullCommits(ctx, ctx.Repo.GitRepo, ctx.Doer, issue) if err != nil { ctx.JSON(http.StatusInternalServerError, err) return diff --git a/services/pull/pull.go b/services/pull/pull.go index 2829e15441..e55d4f5bb1 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -33,7 +33,6 @@ import ( repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - gitea_context "code.gitea.io/gitea/services/context" issue_service "code.gitea.io/gitea/services/issue" notify_service "code.gitea.io/gitea/services/notify" ) @@ -1065,11 +1064,9 @@ type CommitInfo struct { // GetPullCommits returns all commits on given pull request and the last review commit sha // Attention: The last review commit sha must be from the latest review whose commit id is not empty. // So the type of the latest review cannot be "ReviewTypeRequest". -func GetPullCommits(ctx *gitea_context.Context, issue *issues_model.Issue) ([]CommitInfo, string, error) { +func GetPullCommits(ctx context.Context, baseGitRepo *git.Repository, doer *user_model.User, issue *issues_model.Issue) ([]CommitInfo, string, error) { pull := issue.PullRequest - baseGitRepo := ctx.Repo.GitRepo - if err := pull.LoadBaseRepo(ctx); err != nil { return nil, "", err } @@ -1105,11 +1102,11 @@ func GetPullCommits(ctx *gitea_context.Context, issue *issues_model.Issue) ([]Co } var lastReviewCommitID string - if ctx.IsSigned { + if doer != nil { // get last review of current user and store information in context (if available) lastreview, err := issues_model.FindLatestReviews(ctx, issues_model.FindReviewOptions{ IssueID: issue.ID, - ReviewerID: ctx.Doer.ID, + ReviewerID: doer.ID, Types: []issues_model.ReviewType{ issues_model.ReviewTypeApprove, issues_model.ReviewTypeComment,