diff options
Diffstat (limited to 'services/repository')
-rw-r--r-- | services/repository/branch.go | 7 | ||||
-rw-r--r-- | services/repository/files/commit.go | 6 | ||||
-rw-r--r-- | services/repository/files/patch.go | 3 | ||||
-rw-r--r-- | services/repository/files/update.go | 15 | ||||
-rw-r--r-- | services/repository/files/upload.go | 13 | ||||
-rw-r--r-- | services/repository/fork.go | 3 | ||||
-rw-r--r-- | services/repository/push.go | 3 |
7 files changed, 28 insertions, 22 deletions
diff --git a/services/repository/branch.go b/services/repository/branch.go index 88fc67fa8c..6c9a5d76ca 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -11,6 +11,7 @@ import ( "strings" "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" @@ -118,7 +119,7 @@ func RenameBranch(repo *repo_model.Repository, doer *user_model.User, gitRepo *g return "from_not_exist", nil } - if err := models.RenameBranch(repo, from, to, func(isDefault bool) error { + if err := git_model.RenameBranch(repo, from, to, func(isDefault bool) error { err2 := gitRepo.RenameBranch(from, to) if err2 != nil { return err2 @@ -158,7 +159,7 @@ func DeleteBranch(doer *user_model.User, repo *repo_model.Repository, gitRepo *g return ErrBranchIsDefault } - isProtected, err := models.IsProtectedBranch(repo.ID, branchName) + isProtected, err := git_model.IsProtectedBranch(repo.ID, branchName) if err != nil { return err } @@ -196,7 +197,7 @@ func DeleteBranch(doer *user_model.User, repo *repo_model.Repository, gitRepo *g log.Error("Update: %v", err) } - if err := models.AddDeletedBranch(repo.ID, branchName, commit.ID.String(), doer.ID); err != nil { + if err := git_model.AddDeletedBranch(repo.ID, branchName, commit.ID.String(), doer.ID); err != nil { log.Warn("AddDeletedBranch: %v", err) } diff --git a/services/repository/files/commit.go b/services/repository/files/commit.go index 6ecabb4020..ecd981b5ff 100644 --- a/services/repository/files/commit.go +++ b/services/repository/files/commit.go @@ -8,8 +8,8 @@ import ( "context" "fmt" - "code.gitea.io/gitea/models" asymkey_model "code.gitea.io/gitea/models/asymkey" + 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" @@ -20,7 +20,7 @@ import ( // CreateCommitStatus creates a new CommitStatus given a bunch of parameters // NOTE: All text-values will be trimmed from whitespaces. // Requires: Repo, Creator, SHA -func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creator *user_model.User, sha string, status *models.CommitStatus) error { +func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creator *user_model.User, sha string, status *git_model.CommitStatus) error { repoPath := repo.RepoPath() // confirm that commit is exist @@ -36,7 +36,7 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato } gitRepo.Close() - if err := models.NewCommitStatus(models.NewCommitStatusOptions{ + if err := git_model.NewCommitStatus(git_model.NewCommitStatusOptions{ Repo: repo, Creator: creator, SHA: sha, diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go index 73464f31f3..d55d793f28 100644 --- a/services/repository/files/patch.go +++ b/services/repository/files/patch.go @@ -10,6 +10,7 @@ import ( "strings" "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" @@ -66,7 +67,7 @@ func (opts *ApplyDiffPatchOptions) Validate(ctx context.Context, repo *repo_mode return err } } else { - protectedBranch, err := models.GetProtectedBranchBy(ctx, repo.ID, opts.OldBranch) + protectedBranch, err := git_model.GetProtectedBranchBy(ctx, repo.ID, opts.OldBranch) if err != nil { return err } diff --git a/services/repository/files/update.go b/services/repository/files/update.go index a093ee5da7..4615a9153a 100644 --- a/services/repository/files/update.go +++ b/services/repository/files/update.go @@ -13,6 +13,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/charset" @@ -75,8 +76,8 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *repo_model.Repository) (st if setting.LFS.StartServer { pointer, _ := lfs.ReadPointerFromBuffer(buf) if pointer.IsValid() { - meta, err := models.GetLFSMetaObjectByOid(repo.ID, pointer.Oid) - if err != nil && err != models.ErrLFSObjectNotExist { + meta, err := git_model.GetLFSMetaObjectByOid(repo.ID, pointer.Oid) + if err != nil && err != git_model.ErrLFSObjectNotExist { // return default return "UTF-8", false } @@ -364,7 +365,7 @@ func CreateOrUpdateRepoFile(ctx context.Context, repo *repo_model.Repository, do } // Reset the opts.Content to our adjusted content to ensure that LFS gets the correct content opts.Content = content - var lfsMetaObject *models.LFSMetaObject + var lfsMetaObject *git_model.LFSMetaObject if setting.LFS.StartServer && hasOldBranch { // Check there is no way this can return multiple infos @@ -383,7 +384,7 @@ func CreateOrUpdateRepoFile(ctx context.Context, repo *repo_model.Repository, do if err != nil { return nil, err } - lfsMetaObject = &models.LFSMetaObject{Pointer: pointer, RepositoryID: repo.ID} + lfsMetaObject = &git_model.LFSMetaObject{Pointer: pointer, RepositoryID: repo.ID} content = pointer.StringContent() } } @@ -423,7 +424,7 @@ func CreateOrUpdateRepoFile(ctx context.Context, repo *repo_model.Repository, do if lfsMetaObject != nil { // We have an LFS object - create it - lfsMetaObject, err = models.NewLFSMetaObject(lfsMetaObject) + lfsMetaObject, err = git_model.NewLFSMetaObject(lfsMetaObject) if err != nil { return nil, err } @@ -434,7 +435,7 @@ func CreateOrUpdateRepoFile(ctx context.Context, repo *repo_model.Repository, do } if !exist { if err := contentStore.Put(lfsMetaObject.Pointer, strings.NewReader(opts.Content)); err != nil { - if _, err2 := models.RemoveLFSMetaObjectByOid(repo.ID, lfsMetaObject.Oid); err2 != nil { + if _, err2 := git_model.RemoveLFSMetaObjectByOid(repo.ID, lfsMetaObject.Oid); err2 != nil { return nil, fmt.Errorf("Error whilst removing failed inserted LFS object %s: %v (Prev Error: %v)", lfsMetaObject.Oid, err2, err) } return nil, err @@ -462,7 +463,7 @@ func CreateOrUpdateRepoFile(ctx context.Context, repo *repo_model.Repository, do // VerifyBranchProtection verify the branch protection for modifying the given treePath on the given branch func VerifyBranchProtection(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, branchName, treePath string) error { - protectedBranch, err := models.GetProtectedBranchBy(ctx, repo.ID, branchName) + protectedBranch, err := git_model.GetProtectedBranchBy(ctx, repo.ID, branchName) if err != nil { return err } diff --git a/services/repository/files/upload.go b/services/repository/files/upload.go index ff0448fc87..ffc1f4efe9 100644 --- a/services/repository/files/upload.go +++ b/services/repository/files/upload.go @@ -12,6 +12,7 @@ import ( "strings" "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" @@ -32,7 +33,7 @@ type UploadRepoFileOptions struct { type uploadInfo struct { upload *models.Upload - lfsMetaObject *models.LFSMetaObject + lfsMetaObject *git_model.LFSMetaObject } func cleanUpAfterFailure(infos *[]uploadInfo, t *TemporaryUploadRepository, original error) error { @@ -41,7 +42,7 @@ func cleanUpAfterFailure(infos *[]uploadInfo, t *TemporaryUploadRepository, orig continue } if !info.lfsMetaObject.Existing { - if _, err := models.RemoveLFSMetaObjectByOid(t.repo.ID, info.lfsMetaObject.Oid); err != nil { + if _, err := git_model.RemoveLFSMetaObjectByOid(t.repo.ID, info.lfsMetaObject.Oid); err != nil { original = fmt.Errorf("%v, %v", original, err) } } @@ -65,7 +66,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use for i, upload := range uploads { // Check file is not lfs locked, will return nil if lock setting not enabled filepath := path.Join(opts.TreePath, upload.Name) - lfsLock, err := models.GetTreePathLock(repo.ID, filepath) + lfsLock, err := git_model.GetTreePathLock(repo.ID, filepath) if err != nil { return err } @@ -74,7 +75,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use if err != nil { return err } - return models.ErrLFSFileLocked{RepoID: repo.ID, Path: filepath, UserName: u.Name} + return git_model.ErrLFSFileLocked{RepoID: repo.ID, Path: filepath, UserName: u.Name} } names[i] = upload.Name @@ -133,7 +134,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use if infos[i].lfsMetaObject == nil { continue } - infos[i].lfsMetaObject, err = models.NewLFSMetaObject(infos[i].lfsMetaObject) + infos[i].lfsMetaObject, err = git_model.NewLFSMetaObject(infos[i].lfsMetaObject) if err != nil { // OK Now we need to cleanup return cleanUpAfterFailure(&infos, t, err) @@ -175,7 +176,7 @@ func copyUploadedLFSFileIntoRepository(info *uploadInfo, filename2attribute2info return err } - info.lfsMetaObject = &models.LFSMetaObject{Pointer: pointer, RepositoryID: t.repo.ID} + info.lfsMetaObject = &git_model.LFSMetaObject{Pointer: pointer, RepositoryID: t.repo.ID} if objectHash, err = t.HashObject(strings.NewReader(pointer.StringContent())); err != nil { return err diff --git a/services/repository/fork.go b/services/repository/fork.go index f4888cba1d..b274585ed5 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + 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" @@ -101,7 +102,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork } // copy lfs files failure should not be ignored - if err = models.CopyLFS(txCtx, repo, opts.BaseRepo); err != nil { + if err = git_model.CopyLFS(txCtx, repo, opts.BaseRepo); err != nil { return err } diff --git a/services/repository/push.go b/services/repository/push.go index b6741c5ab4..65ac7b660c 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + 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/cache" @@ -252,7 +253,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { notification.NotifyPushCommits(pusher, repo, opts, commits) - if err = models.RemoveDeletedBranchByName(repo.ID, branch); err != nil { + if err = git_model.RemoveDeletedBranchByName(repo.ID, branch); err != nil { log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, branch, err) } |