aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-17 23:17:31 +0800
committerGitHub <noreply@github.com>2021-11-17 23:17:31 +0800
commit5233051e64e90238bb7b6ddf9ecd1513e57bf8e9 (patch)
tree6e21565fd47954877bc14fd66f57d798c86e3300 /routers
parent750a8465f547e9f08a87612c75898d56b8ec1f88 (diff)
downloadgitea-5233051e64e90238bb7b6ddf9ecd1513e57bf8e9.tar.gz
gitea-5233051e64e90238bb7b6ddf9ecd1513e57bf8e9.zip
Move some functions into services/repository (#17677)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/branch.go4
-rw-r--r--routers/init.go7
-rw-r--r--routers/web/repo/branch.go8
3 files changed, 9 insertions, 10 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index c57075e3b8..2e08b56826 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -176,7 +176,7 @@ func CreateBranch(ctx *context.APIContext) {
opt.OldBranchName = ctx.Repo.Repository.DefaultBranch
}
- err := repo_module.CreateNewBranch(ctx.User, ctx.Repo.Repository, opt.OldBranchName, opt.BranchName)
+ err := repo_service.CreateNewBranch(ctx.User, ctx.Repo.Repository, opt.OldBranchName, opt.BranchName)
if err != nil {
if models.IsErrBranchDoesNotExist(err) {
@@ -257,7 +257,7 @@ func ListBranches(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx)
skip, _ := listOptions.GetStartEnd()
- branches, totalNumOfBranches, err := repo_module.GetBranches(ctx.Repo.Repository, skip, listOptions.PageSize)
+ branches, totalNumOfBranches, err := repo_service.GetBranches(ctx.Repo.Repository, skip, listOptions.PageSize)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
return
diff --git a/routers/init.go b/routers/init.go
index 0f19e7f732..762508cee5 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -25,7 +25,6 @@ import (
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/external"
"code.gitea.io/gitea/modules/notification"
- repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/ssh"
"code.gitea.io/gitea/modules/storage"
@@ -45,7 +44,7 @@ import (
repo_migrations "code.gitea.io/gitea/services/migrations"
mirror_service "code.gitea.io/gitea/services/mirror"
pull_service "code.gitea.io/gitea/services/pull"
- "code.gitea.io/gitea/services/repository"
+ repo_service "code.gitea.io/gitea/services/repository"
"code.gitea.io/gitea/services/webhook"
"gitea.com/go-chi/session"
@@ -73,7 +72,7 @@ func mustInitCtx(ctx context.Context, fn func(ctx context.Context) error) {
func InitGitServices() {
setting.NewServices()
mustInit(storage.Init)
- mustInit(repository.NewContext)
+ mustInit(repo_service.NewContext)
}
func syncAppPathForGit(ctx context.Context) error {
@@ -85,7 +84,7 @@ func syncAppPathForGit(ctx context.Context) error {
log.Info("AppPath changed from '%s' to '%s'", runtimeState.LastAppPath, setting.AppPath)
log.Info("re-sync repository hooks ...")
- mustInitCtx(ctx, repo_module.SyncRepositoryHooks)
+ mustInitCtx(ctx, repo_service.SyncRepositoryHooks)
log.Info("re-write ssh public keys ...")
mustInit(models.RewriteAllPublicKeys)
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go
index 991beeace2..10557ff3db 100644
--- a/routers/web/repo/branch.go
+++ b/routers/web/repo/branch.go
@@ -171,7 +171,7 @@ func loadBranches(ctx *context.Context, skip, limit int) ([]*Branch, int) {
return nil, 0
}
- rawBranches, totalNumOfBranches, err := repo_module.GetBranches(ctx.Repo.Repository, skip, limit)
+ rawBranches, totalNumOfBranches, err := repo_service.GetBranches(ctx.Repo.Repository, skip, limit)
if err != nil {
log.Error("GetBranches: %v", err)
ctx.ServerError("GetBranches", err)
@@ -350,11 +350,11 @@ func CreateBranch(ctx *context.Context) {
err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName, "")
}
} else if ctx.Repo.IsViewBranch {
- err = repo_module.CreateNewBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName)
+ err = repo_service.CreateNewBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName)
} else if ctx.Repo.IsViewTag {
- err = repo_module.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName)
+ err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName)
} else {
- err = repo_module.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName)
+ err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName)
}
if err != nil {
if models.IsErrTagAlreadyExists(err) {