summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/http.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 09:27:50 +0800
committerGitHub <noreply@github.com>2021-12-10 09:27:50 +0800
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /routers/web/repo/http.go
parentfb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff)
downloadgitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz
gitea-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'routers/web/repo/http.go')
-rw-r--r--routers/web/repo/http.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go
index 3aa8e84f57..3e12cd3267 100644
--- a/routers/web/repo/http.go
+++ b/routers/web/repo/http.go
@@ -20,8 +20,10 @@ import (
"time"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/login"
"code.gitea.io/gitea/models/perm"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
@@ -129,9 +131,9 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
}
repoExist := true
- repo, err := models.GetRepositoryByName(owner.ID, reponame)
+ repo, err := repo_model.GetRepositoryByName(owner.ID, reponame)
if err != nil {
- if models.IsErrRepoNotExist(err) {
+ if repo_model.IsErrRepoNotExist(err) {
if redirectRepoID, err := models.LookupRepoRedirect(owner.ID, reponame); err == nil {
context.RedirectToRepo(ctx, redirectRepoID)
return
@@ -158,7 +160,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
// don't allow anonymous pulls if organization is not public
if isPublicPull {
- if err := repo.GetOwner(); err != nil {
+ if err := repo.GetOwner(db.DefaultContext); err != nil {
ctx.ServerError("GetOwner", err)
return
}
@@ -273,7 +275,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 models.IsErrUnitTypeNotExist(err) {
+ if repo_model.IsErrUnitTypeNotExist(err) {
ctx.HandleText(http.StatusForbidden, "repository wiki is disabled")
return
}
@@ -295,9 +297,9 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
r.URL.Path = strings.ToLower(r.URL.Path) // blue: In case some repo name has upper case name
- dir := models.RepoPath(username, reponame)
+ dir := repo_model.RepoPath(username, reponame)
if isWiki {
- dir = models.RepoPath(username, wikiRepoName)
+ dir = repo_model.RepoPath(username, wikiRepoName)
}
return &serviceHandler{cfg, w, r, dir, cfg.Env}