summaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-03-22 23:22:54 +0800
committerGitHub <noreply@github.com>2022-03-22 16:22:54 +0100
commit7a550b3af20dad94cf468012a6b817b43b91c1ba (patch)
tree1b836eabf8e911f35d0446c0cdad053cb3572c79 /modules/context
parent2b55422cd71b0b325f054646de5cebf39b72b502 (diff)
downloadgitea-7a550b3af20dad94cf468012a6b817b43b91c1ba.tar.gz
gitea-7a550b3af20dad94cf468012a6b817b43b91c1ba.zip
Use `ctx` instead of `db.DefaultContext` in some packages(routers/services/modules) (#19163)
* Remove `db.DefaultContext` usage in routers, use `ctx` directly * Use `ctx` directly if there is one, remove some `db.DefaultContext` in `services` * Use ctx instead of db.DefaultContext for `cmd` and some `modules` packages * fix incorrect context usage
Diffstat (limited to 'modules/context')
-rw-r--r--modules/context/repo.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index d64380dd95..f8b07ffb05 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -15,7 +15,6 @@ import (
"strings"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
unit_model "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
@@ -256,7 +255,7 @@ func RetrieveBaseRepo(ctx *Context, repo *repo_model.Repository) {
}
ctx.ServerError("GetBaseRepo", err)
return
- } else if err = repo.BaseRepo.GetOwner(db.DefaultContext); err != nil {
+ } else if err = repo.BaseRepo.GetOwner(ctx); err != nil {
ctx.ServerError("BaseRepo.GetOwner", err)
return
}
@@ -273,7 +272,7 @@ func RetrieveTemplateRepo(ctx *Context, repo *repo_model.Repository) {
}
ctx.ServerError("GetTemplateRepo", err)
return
- } else if err = templateRepo.GetOwner(db.DefaultContext); err != nil {
+ } else if err = templateRepo.GetOwner(ctx); err != nil {
ctx.ServerError("TemplateRepo.GetOwner", err)
return
}
@@ -341,7 +340,7 @@ func RedirectToRepo(ctx *Context, redirectRepoID int64) {
func repoAssignment(ctx *Context, repo *repo_model.Repository) {
var err error
- if err = repo.GetOwner(db.DefaultContext); err != nil {
+ if err = repo.GetOwner(ctx); err != nil {
ctx.ServerError("GetOwner", err)
return
}