summaryrefslogtreecommitdiffstats
path: root/routers/web/repo
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-10 10:46:31 +0800
committerGitHub <noreply@github.com>2022-12-10 10:46:31 +0800
commit68704532c28cf09db96c988291b2f82c5e615984 (patch)
treec6537092dc11054f96b202fdb957755ed116cd99 /routers/web/repo
parent097d4e30b180eef30600beef2c08095e2571319c (diff)
downloadgitea-68704532c28cf09db96c988291b2f82c5e615984.tar.gz
gitea-68704532c28cf09db96c988291b2f82c5e615984.zip
Rename almost all Ctx functions (#22071)
Diffstat (limited to 'routers/web/repo')
-rw-r--r--routers/web/repo/cherry_pick.go2
-rw-r--r--routers/web/repo/compare.go2
-rw-r--r--routers/web/repo/editor.go6
-rw-r--r--routers/web/repo/http.go2
-rw-r--r--routers/web/repo/issue.go16
-rw-r--r--routers/web/repo/milestone.go2
-rw-r--r--routers/web/repo/patch.go2
-rw-r--r--routers/web/repo/projects.go2
-rw-r--r--routers/web/repo/release.go2
-rw-r--r--routers/web/repo/repo.go6
-rw-r--r--routers/web/repo/setting.go9
-rw-r--r--routers/web/repo/wiki.go2
12 files changed, 26 insertions, 27 deletions
diff --git a/routers/web/repo/cherry_pick.go b/routers/web/repo/cherry_pick.go
index 2056ad1b37..48bc6959e0 100644
--- a/routers/web/repo/cherry_pick.go
+++ b/routers/web/repo/cherry_pick.go
@@ -177,7 +177,7 @@ func CherryPickPost(ctx *context.Context) {
}
}
- if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(unit.TypePullRequests) {
+ if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ctx.Repo.BranchName) + "..." + util.PathEscapeSegments(form.NewBranchName))
} else {
ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(branchName))
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index b2d8f8645d..d95eeaecc9 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -577,7 +577,7 @@ func PrepareCompareDiff(
if (headCommitID == ci.CompareInfo.MergeBase && !ci.DirectComparison) ||
headCommitID == ci.CompareInfo.BaseCommitID {
ctx.Data["IsNothingToCompare"] = true
- if unit, err := repo.GetUnit(unit.TypePullRequests); err == nil {
+ if unit, err := repo.GetUnit(ctx, unit.TypePullRequests); err == nil {
config := unit.PullRequestsConfig()
if !config.AutodetectManualMerge {
diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go
index 7b064adfc5..e5ba4ad2c1 100644
--- a/routers/web/repo/editor.go
+++ b/routers/web/repo/editor.go
@@ -328,7 +328,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
}
}
- if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(unit.TypePullRequests) {
+ if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ctx.Repo.BranchName) + "..." + util.PathEscapeSegments(form.NewBranchName))
} else {
ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(branchName) + "/" + util.PathEscapeSegments(form.TreePath))
@@ -514,7 +514,7 @@ func DeleteFilePost(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", ctx.Repo.TreePath))
- if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(unit.TypePullRequests) {
+ if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ctx.Repo.BranchName) + "..." + util.PathEscapeSegments(form.NewBranchName))
} else {
treePath := path.Dir(ctx.Repo.TreePath)
@@ -717,7 +717,7 @@ func UploadFilePost(ctx *context.Context) {
return
}
- if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(unit.TypePullRequests) {
+ if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ctx.Repo.BranchName) + "..." + util.PathEscapeSegments(form.NewBranchName))
} else {
ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(branchName) + "/" + util.PathEscapeSegments(form.TreePath))
diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go
index d2450066e3..b2a49e3e3a 100644
--- a/routers/web/repo/http.go
+++ b/routers/web/repo/http.go
@@ -258,7 +258,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
if isWiki {
// Ensure the wiki is enabled before we allow access to it
- if _, err := repo.GetUnit(unit.TypeWiki); err != nil {
+ if _, err := repo.GetUnit(ctx, unit.TypeWiki); err != nil {
if repo_model.IsErrUnitTypeNotExist(err) {
ctx.PlainText(http.StatusForbidden, "repository wiki is disabled")
return
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index b11cc58e41..d315525dac 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -47,7 +47,6 @@ import (
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/utils"
asymkey_service "code.gitea.io/gitea/services/asymkey"
- comment_service "code.gitea.io/gitea/services/comments"
"code.gitea.io/gitea/services/forms"
issue_service "code.gitea.io/gitea/services/issue"
pull_service "code.gitea.io/gitea/services/pull"
@@ -114,7 +113,7 @@ func MustEnableIssues(ctx *context.Context) {
return
}
- unit, err := ctx.Repo.Repository.GetUnit(unit.TypeExternalTracker)
+ unit, err := ctx.Repo.Repository.GetUnit(ctx, unit.TypeExternalTracker)
if err == nil {
ctx.Redirect(unit.ExternalTrackerConfig().ExternalTrackerURL)
return
@@ -1174,7 +1173,7 @@ func getBranchData(ctx *context.Context, issue *issues_model.Issue) {
func ViewIssue(ctx *context.Context) {
if ctx.Params(":type") == "issues" {
// If issue was requested we check if repo has external tracker and redirect
- extIssueUnit, err := ctx.Repo.Repository.GetUnit(unit.TypeExternalTracker)
+ extIssueUnit, err := ctx.Repo.Repository.GetUnit(ctx, unit.TypeExternalTracker)
if err == nil && extIssueUnit != nil {
if extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == markup.IssueNameStyleNumeric || extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == "" {
metas := ctx.Repo.Repository.ComposeMetas()
@@ -1375,7 +1374,7 @@ func ViewIssue(ctx *context.Context) {
comment *issues_model.Comment
participants = make([]*user_model.User, 1, 10)
)
- if ctx.Repo.Repository.IsTimetrackerEnabled() {
+ if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
if ctx.IsSigned {
// Deal with the stopwatch
ctx.Data["IsStopwatchRunning"] = issues_model.StopwatchExists(ctx.Doer.ID, issue.ID)
@@ -1636,7 +1635,7 @@ func ViewIssue(ctx *context.Context) {
}
}
- prUnit, err := repo.GetUnit(unit.TypePullRequests)
+ prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests)
if err != nil {
ctx.ServerError("GetUnit", err)
return
@@ -2709,7 +2708,7 @@ func NewComment(ctx *context.Context) {
return
}
- comment, err := comment_service.CreateIssueComment(ctx, ctx.Doer, ctx.Repo.Repository, issue, form.Content, attachments)
+ comment, err := issue_service.CreateIssueComment(ctx, ctx.Doer, ctx.Repo.Repository, issue, form.Content, attachments)
if err != nil {
ctx.ServerError("CreateIssueComment", err)
return
@@ -2749,8 +2748,7 @@ func UpdateCommentContent(ctx *context.Context) {
})
return
}
-
- if err = comment_service.UpdateComment(ctx, comment, ctx.Doer, oldContent); err != nil {
+ if err = issue_service.UpdateComment(ctx, comment, ctx.Doer, oldContent); err != nil {
ctx.ServerError("UpdateComment", err)
return
}
@@ -2806,7 +2804,7 @@ func DeleteComment(ctx *context.Context) {
return
}
- if err = comment_service.DeleteComment(ctx, ctx.Doer, comment); err != nil {
+ if err = issue_service.DeleteComment(ctx, ctx.Doer, comment); err != nil {
ctx.ServerError("DeleteComment", err)
return
}
diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go
index 0427156397..d712df1001 100644
--- a/routers/web/repo/milestone.go
+++ b/routers/web/repo/milestone.go
@@ -73,7 +73,7 @@ func Milestones(ctx *context.Context) {
ctx.ServerError("GetMilestones", err)
return
}
- if ctx.Repo.Repository.IsTimetrackerEnabled() {
+ if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
if err := miles.LoadTotalTrackedTimes(); err != nil {
ctx.ServerError("LoadTotalTrackedTimes", err)
return
diff --git a/routers/web/repo/patch.go b/routers/web/repo/patch.go
index 27199ba410..12b26f38e9 100644
--- a/routers/web/repo/patch.go
+++ b/routers/web/repo/patch.go
@@ -108,7 +108,7 @@ func NewDiffPatchPost(ctx *context.Context) {
}
}
- if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(unit.TypePullRequests) {
+ if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ctx.Repo.BranchName) + "..." + util.PathEscapeSegments(form.NewBranchName))
} else {
ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(branchName) + "/" + util.PathEscapeSegments(form.TreePath))
diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go
index 73f0916346..75cd290b8f 100644
--- a/routers/web/repo/projects.go
+++ b/routers/web/repo/projects.go
@@ -196,7 +196,7 @@ func DeleteProject(ctx *context.Context) {
return
}
- if err := project_model.DeleteProjectByID(p.ID); err != nil {
+ if err := project_model.DeleteProjectByID(ctx, p.ID); err != nil {
ctx.Flash.Error("DeleteProjectByID: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success"))
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index 0aa1fde8de..2047a1cfb9 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -135,7 +135,7 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
return
}
- count, err := repo_model.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, opts)
+ count, err := repo_model.GetReleaseCountByRepoID(ctx, ctx.Repo.Repository.ID, opts)
if err != nil {
ctx.ServerError("GetReleaseCountByRepoID", err)
return
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index c57564d334..8856ee6626 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -314,12 +314,12 @@ func Action(ctx *context.Context) {
}
func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
- repoTransfer, err := models.GetPendingRepositoryTransfer(ctx.Repo.Repository)
+ repoTransfer, err := models.GetPendingRepositoryTransfer(ctx, ctx.Repo.Repository)
if err != nil {
return err
}
- if err := repoTransfer.LoadAttributes(); err != nil {
+ if err := repoTransfer.LoadAttributes(ctx); err != nil {
return err
}
@@ -333,7 +333,7 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
ctx.Repo.GitRepo = nil
}
- if err := repo_service.TransferOwnership(repoTransfer.Doer, repoTransfer.Recipient, ctx.Repo.Repository, repoTransfer.Teams); err != nil {
+ if err := repo_service.TransferOwnership(ctx, repoTransfer.Doer, repoTransfer.Recipient, ctx.Repo.Repository, repoTransfer.Teams); err != nil {
return err
}
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.success"))
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index 9e47d0bb12..8ba5fc9e34 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -689,7 +689,7 @@ func SettingsPost(ctx *context.Context) {
ctx.Repo.GitRepo = nil
}
- if err := repo_service.StartRepositoryTransfer(ctx.Doer, newOwner, repo, nil); err != nil {
+ if err := repo_service.StartRepositoryTransfer(ctx, ctx.Doer, newOwner, repo, nil); err != nil {
if repo_model.IsErrRepoAlreadyExist(err) {
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), tplSettingsOptions, nil)
} else if models.IsErrRepoTransferInProgress(err) {
@@ -711,7 +711,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- repoTransfer, err := models.GetPendingRepositoryTransfer(ctx.Repo.Repository)
+ repoTransfer, err := models.GetPendingRepositoryTransfer(ctx, ctx.Repo.Repository)
if err != nil {
if models.IsErrNoPendingTransfer(err) {
ctx.Flash.Error("repo.settings.transfer_abort_invalid")
@@ -723,7 +723,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- if err := repoTransfer.LoadAttributes(); err != nil {
+ if err := repoTransfer.LoadAttributes(ctx); err != nil {
ctx.ServerError("LoadRecipient", err)
return
}
@@ -929,7 +929,7 @@ func CollaborationPost(ctx *context.Context) {
}
}
- if err = repo_module.AddCollaborator(ctx.Repo.Repository, u); err != nil {
+ if err = repo_module.AddCollaborator(ctx, ctx.Repo.Repository, u); err != nil {
ctx.ServerError("AddCollaborator", err)
return
}
@@ -945,6 +945,7 @@ func CollaborationPost(ctx *context.Context) {
// ChangeCollaborationAccessMode response for changing access of a collaboration
func ChangeCollaborationAccessMode(ctx *context.Context) {
if err := repo_model.ChangeCollaborationAccessMode(
+ ctx,
ctx.Repo.Repository,
ctx.FormInt64("uid"),
perm.AccessMode(ctx.FormInt("mode"))); err != nil {
diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go
index 885f84543c..b50a4be802 100644
--- a/routers/web/repo/wiki.go
+++ b/routers/web/repo/wiki.go
@@ -59,7 +59,7 @@ func MustEnableWiki(ctx *context.Context) {
return
}
- unit, err := ctx.Repo.Repository.GetUnit(unit.TypeExternalWiki)
+ unit, err := ctx.Repo.Repository.GetUnit(ctx, unit.TypeExternalWiki)
if err == nil {
ctx.Redirect(unit.ExternalWikiConfig().ExternalWikiURL)
return