summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-01-12 20:11:17 +0800
committerGitHub <noreply@github.com>2020-01-12 20:11:17 +0800
commitb465d0d78793da6e67890a7cb9d3ae1b807c53ca (patch)
tree1cdfb83699ad2fd31d5835bb2ac1e1b579eaf784 /services
parent5765212c6dbcaeb27779707af3ca57775e535bd9 (diff)
downloadgitea-b465d0d78793da6e67890a7cb9d3ae1b807c53ca.tar.gz
gitea-b465d0d78793da6e67890a7cb9d3ae1b807c53ca.zip
Move create/fork repository from models to modules/repository (#9489)
* Move create/fork repository from models to modules/repository * fix wrong reference * fix test * fix test * fix lint * Fix DBContext * remove duplicated TestMain * fix lint * fix conflicts
Diffstat (limited to 'services')
-rw-r--r--services/mirror/mirror.go2
-rw-r--r--services/mirror/mirror_test.go2
-rw-r--r--services/repository/generate.go5
-rw-r--r--services/repository/repository.go5
4 files changed, 8 insertions, 6 deletions
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index d4f97c2600..0c7f3ae3c7 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -217,7 +217,7 @@ func runSync(m *models.Mirror) ([]*mirrorSyncResult, bool) {
}
gitRepo.Close()
- if err := m.Repo.UpdateSize(); err != nil {
+ if err := m.Repo.UpdateSize(models.DefaultDBContext()); err != nil {
log.Error("Failed to update size for mirror repository: %v", err)
}
diff --git a/services/mirror/mirror_test.go b/services/mirror/mirror_test.go
index 816ef230fd..25e499ad78 100644
--- a/services/mirror/mirror_test.go
+++ b/services/mirror/mirror_test.go
@@ -38,7 +38,7 @@ func TestRelease_MirrorDelete(t *testing.T) {
Releases: false,
}
- mirrorRepo, err := models.CreateRepository(user, user, models.CreateRepoOptions{
+ mirrorRepo, err := repository.CreateRepository(user, user, models.CreateRepoOptions{
Name: opts.RepoName,
Description: opts.Description,
IsPrivate: opts.Private,
diff --git a/services/repository/generate.go b/services/repository/generate.go
index f7e8ebd8c4..95e5cdc6c2 100644
--- a/services/repository/generate.go
+++ b/services/repository/generate.go
@@ -8,20 +8,21 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
+ repo_module "code.gitea.io/gitea/modules/repository"
)
// GenerateRepository generates a repository from a template
func GenerateRepository(doer, owner *models.User, templateRepo *models.Repository, opts models.GenerateRepoOptions) (_ *models.Repository, err error) {
var generateRepo *models.Repository
if err = models.WithTx(func(ctx models.DBContext) error {
- generateRepo, err = models.GenerateRepository(ctx, doer, owner, templateRepo, opts)
+ generateRepo, err = repo_module.GenerateRepository(ctx, doer, owner, templateRepo, opts)
if err != nil {
return err
}
// Git Content
if opts.GitContent && !templateRepo.IsEmpty {
- if err = models.GenerateGitContent(ctx, templateRepo, generateRepo); err != nil {
+ if err = repo_module.GenerateGitContent(ctx, templateRepo, generateRepo); err != nil {
return err
}
}
diff --git a/services/repository/repository.go b/services/repository/repository.go
index 2fb45bb617..eea8b352b4 100644
--- a/services/repository/repository.go
+++ b/services/repository/repository.go
@@ -10,11 +10,12 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
+ repo_module "code.gitea.io/gitea/modules/repository"
)
// CreateRepository creates a repository for the user/organization.
func CreateRepository(doer, owner *models.User, opts models.CreateRepoOptions) (*models.Repository, error) {
- repo, err := models.CreateRepository(doer, owner, opts)
+ repo, err := repo_module.CreateRepository(doer, owner, opts)
if err != nil {
if repo != nil {
if errDelete := models.DeleteRepository(doer, owner.ID, repo.ID); errDelete != nil {
@@ -31,7 +32,7 @@ func CreateRepository(doer, owner *models.User, opts models.CreateRepoOptions) (
// ForkRepository forks a repository
func ForkRepository(doer, u *models.User, oldRepo *models.Repository, name, desc string) (*models.Repository, error) {
- repo, err := models.ForkRepository(doer, u, oldRepo, name, desc)
+ repo, err := repo_module.ForkRepository(doer, u, oldRepo, name, desc)
if err != nil {
if repo != nil {
if errDelete := models.DeleteRepository(doer, u.ID, repo.ID); errDelete != nil {