summaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-03 10:48:26 +0800
committerGitHub <noreply@github.com>2022-12-03 10:48:26 +0800
commit0a7d3ff786508284224ada17956a65bb759d9265 (patch)
tree4860fca95c1432ab59c6723ee2b053b1c7d6779d /modules/context
parent8698458f48eafeab21014db544aa7160368856e1 (diff)
downloadgitea-0a7d3ff786508284224ada17956a65bb759d9265.tar.gz
gitea-0a7d3ff786508284224ada17956a65bb759d9265.zip
refactor some functions to support ctx as first parameter (#21878)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/context')
-rw-r--r--modules/context/context.go2
-rw-r--r--modules/context/repo.go6
2 files changed, 4 insertions, 4 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index 0d632b67c0..0fe00bf787 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -139,7 +139,7 @@ func (ctx *Context) IsUserRepoReaderAny() bool {
// RedirectToUser redirect to a differently-named user
func RedirectToUser(ctx *Context, userName string, redirectUserID int64) {
- user, err := user_model.GetUserByID(redirectUserID)
+ user, err := user_model.GetUserByID(ctx, redirectUserID)
if err != nil {
ctx.ServerError("GetUserByID", err)
return
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 57cf2fae5a..a50cb15abe 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -264,7 +264,7 @@ func (r *Repository) GetEditorconfig(optCommit ...*git.Commit) (*editorconfig.Ed
// RetrieveBaseRepo retrieves base repository
func RetrieveBaseRepo(ctx *Context, repo *repo_model.Repository) {
// Non-fork repository will not return error in this method.
- if err := repo.GetBaseRepo(); err != nil {
+ if err := repo.GetBaseRepo(ctx); err != nil {
if repo_model.IsErrRepoNotExist(err) {
repo.IsFork = false
repo.ForkID = 0
@@ -335,7 +335,7 @@ func RedirectToRepo(ctx *Context, redirectRepoID int64) {
ownerName := ctx.Params(":username")
previousRepoName := ctx.Params(":reponame")
- repo, err := repo_model.GetRepositoryByID(redirectRepoID)
+ repo, err := repo_model.GetRepositoryByID(ctx, redirectRepoID)
if err != nil {
ctx.ServerError("GetRepositoryByID", err)
return
@@ -410,7 +410,7 @@ func RepoIDAssignment() func(ctx *Context) {
repoID := ctx.ParamsInt64(":repoid")
// Get repository.
- repo, err := repo_model.GetRepositoryByID(repoID)
+ repo, err := repo_model.GetRepositoryByID(ctx, repoID)
if err != nil {
if repo_model.IsErrRepoNotExist(err) {
ctx.NotFound("GetRepositoryByID", nil)