summaryrefslogtreecommitdiffstats
path: root/services/pull
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-20 22:08:52 +0800
committerGitHub <noreply@github.com>2022-05-20 22:08:52 +0800
commitfd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch)
tree50038348ec10485f72344f3ac80324e04abc1283 /services/pull
parentd81e31ad7826a81fc7139f329f250594610a274b (diff)
downloadgitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz
gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
Diffstat (limited to 'services/pull')
-rw-r--r--services/pull/check.go2
-rw-r--r--services/pull/commit_status.go2
-rw-r--r--services/pull/pull.go6
-rw-r--r--services/pull/review.go10
4 files changed, 10 insertions, 10 deletions
diff --git a/services/pull/check.go b/services/pull/check.go
index d88dd3a550..94e7ca7161 100644
--- a/services/pull/check.go
+++ b/services/pull/check.go
@@ -99,7 +99,7 @@ func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *acce
if err := CheckPullBranchProtections(ctx, pr, false); err != nil {
if models.IsErrDisallowedToMerge(err) {
if force {
- if isRepoAdmin, err2 := access_model.IsUserRepoAdminCtx(ctx, pr.BaseRepo, doer); err2 != nil {
+ if isRepoAdmin, err2 := access_model.IsUserRepoAdmin(ctx, pr.BaseRepo, doer); err2 != nil {
return err2
} else if !isRepoAdmin {
return err
diff --git a/services/pull/commit_status.go b/services/pull/commit_status.go
index ec4cc2aa07..539b3c8520 100644
--- a/services/pull/commit_status.go
+++ b/services/pull/commit_status.go
@@ -132,7 +132,7 @@ func GetPullRequestCommitStatusState(ctx context.Context, pr *models.PullRequest
return "", errors.Wrap(err, "LoadBaseRepo")
}
- commitStatuses, _, err := models.GetLatestCommitStatusCtx(ctx, pr.BaseRepo.ID, sha, db.ListOptions{})
+ commitStatuses, _, err := models.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{})
if err != nil {
return "", errors.Wrap(err, "GetLatestCommitStatus")
}
diff --git a/services/pull/pull.go b/services/pull/pull.go
index b94b6769a4..efac3f019e 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -290,7 +290,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
if err != nil {
log.Error("GetDiverging: %v", err)
} else {
- err = pr.UpdateCommitDivergence(divergence.Ahead, divergence.Behind)
+ err = pr.UpdateCommitDivergence(ctx, divergence.Ahead, divergence.Behind)
if err != nil {
log.Error("UpdateCommitDivergence: %v", err)
}
@@ -336,7 +336,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
log.Error("GetDiverging: %v", err)
}
} else {
- err = pr.UpdateCommitDivergence(divergence.Ahead, divergence.Behind)
+ err = pr.UpdateCommitDivergence(ctx, divergence.Ahead, divergence.Behind)
if err != nil {
log.Error("UpdateCommitDivergence: %v", err)
}
@@ -793,7 +793,7 @@ func getAllCommitStatus(gitRepo *git.Repository, pr *models.PullRequest) (status
return nil, nil, shaErr
}
- statuses, _, err = models.GetLatestCommitStatus(pr.BaseRepo.ID, sha, db.ListOptions{})
+ statuses, _, err = models.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{})
lastStatus = models.CalcCommitStatus(statuses)
return statuses, lastStatus, err
}
diff --git a/services/pull/review.go b/services/pull/review.go
index 940fe4470d..eac7279f9b 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -71,13 +71,13 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
return comment, nil
}
- review, err := models.GetCurrentReview(doer, issue)
+ review, err := models.GetCurrentReview(ctx, doer, issue)
if err != nil {
if !models.IsErrReviewNotExist(err) {
return nil, err
}
- if review, err = models.CreateReview(models.CreateReviewOptions{
+ if review, err = models.CreateReview(ctx, models.CreateReviewOptions{
Type: models.ReviewTypePending,
Reviewer: doer,
Issue: issue,
@@ -135,7 +135,7 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
head := pr.GetGitRefName()
if line > 0 {
if reviewID != 0 {
- first, err := models.FindComments(&models.FindCommentsOptions{
+ first, err := models.FindComments(ctx, &models.FindCommentsOptions{
ReviewID: reviewID,
Line: line,
TreePath: treePath,
@@ -152,7 +152,7 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
} else if err != nil && !models.IsErrCommentNotExist(err) {
return nil, fmt.Errorf("Find first comment for %d line %d path %s. Error: %v", reviewID, line, treePath, err)
} else {
- review, err := models.GetReviewByID(reviewID)
+ review, err := models.GetReviewByID(ctx, reviewID)
if err == nil && len(review.CommitID) > 0 {
head = review.CommitID
} else if err != nil && !models.IsErrReviewNotExist(err) {
@@ -272,7 +272,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
// DismissReview dismissing stale review by repo admin
func DismissReview(ctx context.Context, reviewID int64, message string, doer *user_model.User, isDismiss bool) (comment *models.Comment, err error) {
- review, err := models.GetReviewByID(reviewID)
+ review, err := models.GetReviewByID(ctx, reviewID)
if err != nil {
return
}