summaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-12 23:51:54 +0800
committerGitHub <noreply@github.com>2022-06-12 23:51:54 +0800
commit110fc57cbcf293c19ed7017d8ea528b4bbbd7396 (patch)
treeb36eb2ee0e3f8417a35ad095e25880b778ded0ba /modules/repository
parenta9dc9b06e4a4106ec8315fe7b2922efa440ca199 (diff)
downloadgitea-110fc57cbcf293c19ed7017d8ea528b4bbbd7396.tar.gz
gitea-110fc57cbcf293c19ed7017d8ea528b4bbbd7396.zip
Move some code into models/git (#19879)
* Move access and repo permission to models/perm/access * fix test * Move some git related files into sub package models/git * Fix build * fix git test * move lfs to sub package * move more git related functions to models/git * Move functions sequence * Some improvements per @KN4CK3R and @delvh
Diffstat (limited to 'modules/repository')
-rw-r--r--modules/repository/create.go3
-rw-r--r--modules/repository/generate.go3
-rw-r--r--modules/repository/repo.go11
3 files changed, 10 insertions, 7 deletions
diff --git a/modules/repository/create.go b/modules/repository/create.go
index 95bb825403..3d04dba70f 100644
--- a/modules/repository/create.go
+++ b/modules/repository/create.go
@@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ git_model "code.gitea.io/gitea/models/git"
access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
@@ -146,7 +147,7 @@ func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error {
return fmt.Errorf("updateSize: %v", err)
}
- lfsSize, err := models.GetRepoLFSSize(ctx, repo.ID)
+ lfsSize, err := git_model.GetRepoLFSSize(ctx, repo.ID)
if err != nil {
return fmt.Errorf("updateSize: GetLFSMetaObjects: %v", err)
}
diff --git a/modules/repository/generate.go b/modules/repository/generate.go
index 94bb6e6429..8f7b4c885d 100644
--- a/modules/repository/generate.go
+++ b/modules/repository/generate.go
@@ -16,6 +16,7 @@ import (
"time"
"code.gitea.io/gitea/models"
+ git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
@@ -278,7 +279,7 @@ func GenerateGitContent(ctx context.Context, templateRepo, generateRepo *repo_mo
return fmt.Errorf("failed to update size for repository: %v", err)
}
- if err := models.CopyLFS(ctx, generateRepo, templateRepo); err != nil {
+ if err := git_model.CopyLFS(ctx, generateRepo, templateRepo); err != nil {
return fmt.Errorf("failed to copy LFS: %v", err)
}
return nil
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 281999a1eb..436045146a 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -15,6 +15,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ git_model "code.gitea.io/gitea/models/git"
"code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
@@ -390,7 +391,7 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
defer content.Close()
- _, err := models.NewLFSMetaObject(&models.LFSMetaObject{Pointer: p, RepositoryID: repo.ID})
+ _, err := git_model.NewLFSMetaObject(&git_model.LFSMetaObject{Pointer: p, RepositoryID: repo.ID})
if err != nil {
log.Error("Repo[%-v]: Error creating LFS meta object %-v: %v", repo, p, err)
return err
@@ -398,7 +399,7 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
if err := contentStore.Put(p, content); err != nil {
log.Error("Repo[%-v]: Error storing content for LFS meta object %-v: %v", repo, p, err)
- if _, err2 := models.RemoveLFSMetaObjectByOid(repo.ID, p.Oid); err2 != nil {
+ if _, err2 := git_model.RemoveLFSMetaObjectByOid(repo.ID, p.Oid); err2 != nil {
log.Error("Repo[%-v]: Error removing LFS meta object %-v: %v", repo, p, err2)
}
return err
@@ -417,8 +418,8 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
var batch []lfs.Pointer
for pointerBlob := range pointerChan {
- meta, err := models.GetLFSMetaObjectByOid(repo.ID, pointerBlob.Oid)
- if err != nil && err != models.ErrLFSObjectNotExist {
+ meta, err := git_model.GetLFSMetaObjectByOid(repo.ID, pointerBlob.Oid)
+ if err != nil && err != git_model.ErrLFSObjectNotExist {
log.Error("Repo[%-v]: Error querying LFS meta object %-v: %v", repo, pointerBlob.Pointer, err)
return err
}
@@ -437,7 +438,7 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
if exist {
log.Trace("Repo[%-v]: LFS object %-v already present; creating meta object", repo, pointerBlob.Pointer)
- _, err := models.NewLFSMetaObject(&models.LFSMetaObject{Pointer: pointerBlob.Pointer, RepositoryID: repo.ID})
+ _, err := git_model.NewLFSMetaObject(&git_model.LFSMetaObject{Pointer: pointerBlob.Pointer, RepositoryID: repo.ID})
if err != nil {
log.Error("Repo[%-v]: Error creating LFS meta object %-v: %v", repo, pointerBlob.Pointer, err)
return err