aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-16 21:30:11 +0800
committerGitHub <noreply@github.com>2021-11-16 21:30:11 +0800
commit48ccd325a1b81a58ac6d1d5d94fc4e90974599ea (patch)
treee7bb31d69343dd9845a1b0df013b093c8720f14b /routers
parent447428f44659cee0e94e1c444f6291defac2bda2 (diff)
downloadgitea-48ccd325a1b81a58ac6d1d5d94fc4e90974599ea.tar.gz
gitea-48ccd325a1b81a58ac6d1d5d94fc4e90974599ea.zip
Move some functions into services/repository (#17660)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/admin/adopt.go8
-rw-r--r--routers/api/v1/admin/cron.go2
-rw-r--r--routers/init.go2
-rw-r--r--routers/web/admin/admin.go2
-rw-r--r--routers/web/admin/repos.go7
-rw-r--r--routers/web/repo/setting.go2
-rw-r--r--routers/web/user/setting/adopt.go6
7 files changed, 14 insertions, 15 deletions
diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go
index 9c1b9fc0f8..184a2941a8 100644
--- a/routers/api/v1/admin/adopt.go
+++ b/routers/api/v1/admin/adopt.go
@@ -9,9 +9,9 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/api/v1/utils"
+ repo_service "code.gitea.io/gitea/services/repository"
)
// ListUnadoptedRepositories lists the unadopted repositories that match the provided names
@@ -41,7 +41,7 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
listOptions := utils.GetListOptions(ctx)
- repoNames, count, err := repository.ListUnadoptedRepositories(ctx.FormString("query"), &listOptions)
+ repoNames, count, err := repo_service.ListUnadoptedRepositories(ctx.FormString("query"), &listOptions)
if err != nil {
ctx.InternalServerError(err)
}
@@ -104,7 +104,7 @@ func AdoptRepository(ctx *context.APIContext) {
ctx.NotFound()
return
}
- if _, err := repository.AdoptRepository(ctx.User, ctxUser, models.CreateRepoOptions{
+ if _, err := repo_service.AdoptRepository(ctx.User, ctxUser, models.CreateRepoOptions{
Name: repoName,
IsPrivate: true,
}); err != nil {
@@ -167,7 +167,7 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) {
return
}
- if err := repository.DeleteUnadoptedRepository(ctx.User, ctxUser, repoName); err != nil {
+ if err := repo_service.DeleteUnadoptedRepository(ctx.User, ctxUser, repoName); err != nil {
ctx.InternalServerError(err)
return
}
diff --git a/routers/api/v1/admin/cron.go b/routers/api/v1/admin/cron.go
index 970fad8388..1476872a90 100644
--- a/routers/api/v1/admin/cron.go
+++ b/routers/api/v1/admin/cron.go
@@ -8,11 +8,11 @@ import (
"net/http"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/cron"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/api/v1/utils"
+ "code.gitea.io/gitea/services/cron"
)
// ListCronTasks api for getting cron tasks
diff --git a/routers/init.go b/routers/init.go
index 80e2fec095..6df524dd57 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -15,7 +15,6 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/appstate"
"code.gitea.io/gitea/modules/cache"
- "code.gitea.io/gitea/modules/cron"
"code.gitea.io/gitea/modules/eventsource"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/highlight"
@@ -42,6 +41,7 @@ import (
"code.gitea.io/gitea/services/archiver"
"code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/auth/source/oauth2"
+ "code.gitea.io/gitea/services/cron"
"code.gitea.io/gitea/services/mailer"
mirror_service "code.gitea.io/gitea/services/mirror"
pull_service "code.gitea.io/gitea/services/pull"
diff --git a/routers/web/admin/admin.go b/routers/web/admin/admin.go
index 223114dae1..8cbe852718 100644
--- a/routers/web/admin/admin.go
+++ b/routers/web/admin/admin.go
@@ -18,7 +18,6 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/cron"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
@@ -28,6 +27,7 @@ import (
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/updatechecker"
"code.gitea.io/gitea/modules/web"
+ "code.gitea.io/gitea/services/cron"
"code.gitea.io/gitea/services/forms"
"code.gitea.io/gitea/services/mailer"
diff --git a/routers/web/admin/repos.go b/routers/web/admin/repos.go
index 2f4d182af8..a13f7317e4 100644
--- a/routers/web/admin/repos.go
+++ b/routers/web/admin/repos.go
@@ -14,7 +14,6 @@ import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/web/explore"
@@ -95,7 +94,7 @@ func UnadoptedRepos(ctx *context.Context) {
}
ctx.Data["Keyword"] = q
- repoNames, count, err := repository.ListUnadoptedRepositories(q, &opts)
+ repoNames, count, err := repo_service.ListUnadoptedRepositories(q, &opts)
if err != nil {
ctx.ServerError("ListUnadoptedRepositories", err)
}
@@ -147,7 +146,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
if has || !isDir {
// Fallthrough to failure mode
} else if action == "adopt" {
- if _, err := repository.AdoptRepository(ctx.User, ctxUser, models.CreateRepoOptions{
+ if _, err := repo_service.AdoptRepository(ctx.User, ctxUser, models.CreateRepoOptions{
Name: dirSplit[1],
IsPrivate: true,
}); err != nil {
@@ -156,7 +155,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("repo.adopt_preexisting_success", dir))
} else if action == "delete" {
- if err := repository.DeleteUnadoptedRepository(ctx.User, ctxUser, dirSplit[1]); err != nil {
+ if err := repo_service.DeleteUnadoptedRepository(ctx.User, ctxUser, dirSplit[1]); err != nil {
ctx.ServerError("repository.AdoptRepository", err)
return
}
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index b104ede005..456084f086 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -557,7 +557,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- if err := repository.ConvertForkToNormalRepository(repo); err != nil {
+ if err := repo_service.ConvertForkToNormalRepository(repo); err != nil {
log.Error("Unable to convert repository %-v from fork. Error: %v", repo, err)
ctx.ServerError("Convert Fork", err)
return
diff --git a/routers/web/user/setting/adopt.go b/routers/web/user/setting/adopt.go
index 2caccb69a5..948cc1e936 100644
--- a/routers/web/user/setting/adopt.go
+++ b/routers/web/user/setting/adopt.go
@@ -9,9 +9,9 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
+ repo_service "code.gitea.io/gitea/services/repository"
)
// AdoptOrDeleteRepository adopts or deletes a repository
@@ -44,7 +44,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
if has || !isDir {
// Fallthrough to failure mode
} else if action == "adopt" && allowAdopt {
- if _, err := repository.AdoptRepository(ctxUser, ctxUser, models.CreateRepoOptions{
+ if _, err := repo_service.AdoptRepository(ctxUser, ctxUser, models.CreateRepoOptions{
Name: dir,
IsPrivate: true,
}); err != nil {
@@ -53,7 +53,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("repo.adopt_preexisting_success", dir))
} else if action == "delete" && allowDelete {
- if err := repository.DeleteUnadoptedRepository(ctxUser, ctxUser, dir); err != nil {
+ if err := repo_service.DeleteUnadoptedRepository(ctxUser, ctxUser, dir); err != nil {
ctx.ServerError("repository.AdoptRepository", err)
return
}