diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-06-12 23:51:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-12 23:51:54 +0800 |
commit | 110fc57cbcf293c19ed7017d8ea528b4bbbd7396 (patch) | |
tree | b36eb2ee0e3f8417a35ad095e25880b778ded0ba /models/repo.go | |
parent | a9dc9b06e4a4106ec8315fe7b2922efa440ca199 (diff) | |
download | gitea-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 'models/repo.go')
-rw-r--r-- | models/repo.go | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/models/repo.go b/models/repo.go index fff9cc5271..a8aa18381d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -15,6 +15,7 @@ import ( admin_model "code.gitea.io/gitea/models/admin" asymkey_model "code.gitea.io/gitea/models/asymkey" "code.gitea.io/gitea/models/db" + git_model "code.gitea.io/gitea/models/git" issues_model "code.gitea.io/gitea/models/issues" "code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/models/perm" @@ -34,9 +35,6 @@ import ( "xorm.io/builder" ) -// ItemsPerPage maximum items per page in forks, watchers and stars of a repo -var ItemsPerPage = 40 - // NewRepoContext creates a new repository context func NewRepoContext() { unit.LoadUnitConfig() @@ -284,16 +282,16 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error { &Action{RepoID: repo.ID}, &repo_model.Collaboration{RepoID: repoID}, &Comment{RefRepoID: repoID}, - &CommitStatus{RepoID: repoID}, - &DeletedBranch{RepoID: repoID}, + &git_model.CommitStatus{RepoID: repoID}, + &git_model.DeletedBranch{RepoID: repoID}, &webhook.HookTask{RepoID: repoID}, - &LFSLock{RepoID: repoID}, + &git_model.LFSLock{RepoID: repoID}, &repo_model.LanguageStat{RepoID: repoID}, &issues_model.Milestone{RepoID: repoID}, &repo_model.Mirror{RepoID: repoID}, &Notification{RepoID: repoID}, - &ProtectedBranch{RepoID: repoID}, - &ProtectedTag{RepoID: repoID}, + &git_model.ProtectedBranch{RepoID: repoID}, + &git_model.ProtectedTag{RepoID: repoID}, &repo_model.PushMirror{RepoID: repoID}, &Release{RepoID: repoID}, &repo_model.RepoIndexerStatus{RepoID: repoID}, @@ -357,14 +355,14 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error { } // Remove LFS objects - var lfsObjects []*LFSMetaObject + var lfsObjects []*git_model.LFSMetaObject if err = sess.Where("repository_id=?", repoID).Find(&lfsObjects); err != nil { return err } lfsPaths := make([]string, 0, len(lfsObjects)) for _, v := range lfsObjects { - count, err := db.CountByBean(ctx, &LFSMetaObject{Pointer: lfs.Pointer{Oid: v.Oid}}) + count, err := db.CountByBean(ctx, &git_model.LFSMetaObject{Pointer: lfs.Pointer{Oid: v.Oid}}) if err != nil { return err } @@ -375,7 +373,7 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error { lfsPaths = append(lfsPaths, v.RelativePath()) } - if _, err := db.DeleteByBean(ctx, &LFSMetaObject{RepositoryID: repoID}); err != nil { + if _, err := db.DeleteByBean(ctx, &git_model.LFSMetaObject{RepositoryID: repoID}); err != nil { return err } |