summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/pull.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-11-19 09:12:33 +0100
committerGitHub <noreply@github.com>2022-11-19 16:12:33 +0800
commit044c754ea53f5b81f451451df53aea366f6f700a (patch)
tree45688c28a84f87f71ec3f99eb0e8456eb7d19c42 /routers/web/repo/pull.go
parentfefdb7ffd11bbfbff66dae8e88681ec840dedfde (diff)
downloadgitea-044c754ea53f5b81f451451df53aea366f6f700a.tar.gz
gitea-044c754ea53f5b81f451451df53aea366f6f700a.zip
Add `context.Context` to more methods (#21546)
This PR adds a context parameter to a bunch of methods. Some helper `xxxCtx()` methods got replaced with the normal name now. Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/web/repo/pull.go')
-rw-r--r--routers/web/repo/pull.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index 41eac7cc39..870bc1773b 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -281,7 +281,7 @@ func checkPullInfo(ctx *context.Context) *issues_model.Issue {
}
return nil
}
- if err = issue.LoadPoster(); err != nil {
+ if err = issue.LoadPoster(ctx); err != nil {
ctx.ServerError("LoadPoster", err)
return nil
}
@@ -297,12 +297,12 @@ func checkPullInfo(ctx *context.Context) *issues_model.Issue {
return nil
}
- if err = issue.LoadPullRequest(); err != nil {
+ if err = issue.LoadPullRequest(ctx); err != nil {
ctx.ServerError("LoadPullRequest", err)
return nil
}
- if err = issue.PullRequest.LoadHeadRepoCtx(ctx); err != nil {
+ if err = issue.PullRequest.LoadHeadRepo(ctx); err != nil {
ctx.ServerError("LoadHeadRepo", err)
return nil
}
@@ -319,12 +319,12 @@ func checkPullInfo(ctx *context.Context) *issues_model.Issue {
}
func setMergeTarget(ctx *context.Context, pull *issues_model.PullRequest) {
- if ctx.Repo.Owner.Name == pull.MustHeadUserName() {
+ if ctx.Repo.Owner.Name == pull.MustHeadUserName(ctx) {
ctx.Data["HeadTarget"] = pull.HeadBranch
} else if pull.HeadRepo == nil {
- ctx.Data["HeadTarget"] = pull.MustHeadUserName() + ":" + pull.HeadBranch
+ ctx.Data["HeadTarget"] = pull.MustHeadUserName(ctx) + ":" + pull.HeadBranch
} else {
- ctx.Data["HeadTarget"] = pull.MustHeadUserName() + "/" + pull.HeadRepo.Name + ":" + pull.HeadBranch
+ ctx.Data["HeadTarget"] = pull.MustHeadUserName(ctx) + "/" + pull.HeadRepo.Name + ":" + pull.HeadBranch
}
ctx.Data["BaseTarget"] = pull.BaseBranch
ctx.Data["HeadBranchHTMLURL"] = pull.GetHeadBranchHTMLURL()
@@ -416,12 +416,12 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
repo := ctx.Repo.Repository
pull := issue.PullRequest
- if err := pull.LoadHeadRepoCtx(ctx); err != nil {
+ if err := pull.LoadHeadRepo(ctx); err != nil {
ctx.ServerError("LoadHeadRepo", err)
return nil
}
- if err := pull.LoadBaseRepoCtx(ctx); err != nil {
+ if err := pull.LoadBaseRepo(ctx); err != nil {
ctx.ServerError("LoadBaseRepo", err)
return nil
}
@@ -606,7 +606,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
if pull.IsWorkInProgress() {
ctx.Data["IsPullWorkInProgress"] = true
- ctx.Data["WorkInProgressPrefix"] = pull.GetWorkInProgressPrefix()
+ ctx.Data["WorkInProgressPrefix"] = pull.GetWorkInProgressPrefix(ctx)
}
if pull.IsFilesConflicted() {
@@ -834,11 +834,11 @@ func UpdatePullRequest(ctx *context.Context) {
rebase := ctx.FormString("style") == "rebase"
- if err := issue.PullRequest.LoadBaseRepoCtx(ctx); err != nil {
+ if err := issue.PullRequest.LoadBaseRepo(ctx); err != nil {
ctx.ServerError("LoadBaseRepo", err)
return
}
- if err := issue.PullRequest.LoadHeadRepoCtx(ctx); err != nil {
+ if err := issue.PullRequest.LoadHeadRepo(ctx); err != nil {
ctx.ServerError("LoadHeadRepo", err)
return
}
@@ -974,7 +974,7 @@ func MergePullRequest(ctx *context.Context) {
message := strings.TrimSpace(form.MergeTitleField)
if len(message) == 0 {
var err error
- message, err = pull_service.GetDefaultMergeMessage(ctx.Repo.GitRepo, pr, repo_model.MergeStyle(form.Do))
+ message, err = pull_service.GetDefaultMergeMessage(ctx, ctx.Repo.GitRepo, pr, repo_model.MergeStyle(form.Do))
if err != nil {
ctx.ServerError("GetDefaultMergeMessage", err)
return
@@ -1296,14 +1296,14 @@ func CleanUpPullRequest(ctx *context.Context) {
return
}
- if err := pr.LoadHeadRepoCtx(ctx); err != nil {
+ if err := pr.LoadHeadRepo(ctx); err != nil {
ctx.ServerError("LoadHeadRepo", err)
return
} else if pr.HeadRepo == nil {
// Forked repository has already been deleted
ctx.NotFound("CleanUpPullRequest", nil)
return
- } else if err = pr.LoadBaseRepoCtx(ctx); err != nil {
+ } else if err = pr.LoadBaseRepo(ctx); err != nil {
ctx.ServerError("LoadBaseRepo", err)
return
} else if err = pr.HeadRepo.GetOwner(ctx); err != nil {
@@ -1499,7 +1499,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
}
return
}
- notification.NotifyPullRequestChangeTargetBranch(ctx.Doer, pr, targetBranch)
+ notification.NotifyPullRequestChangeTargetBranch(ctx, ctx.Doer, pr, targetBranch)
ctx.JSON(http.StatusOK, map[string]interface{}{
"base_branch": pr.BaseBranch,