summaryrefslogtreecommitdiffstats
path: root/services/repository/files/temp_repo.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-09 00:46:32 +0800
committerGitHub <noreply@github.com>2022-05-08 18:46:32 +0200
commit4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65 (patch)
treefee132403adea441987ce25809c764e00fd962cd /services/repository/files/temp_repo.go
parentd4834071da9ce010fd4677ef339c598dd23dc130 (diff)
downloadgitea-4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65.tar.gz
gitea-4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65.zip
Move some helper files out of models (#19355)
* Move some helper files out of models * Some improvements Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'services/repository/files/temp_repo.go')
-rw-r--r--services/repository/files/temp_repo.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go
index 8ebf991382..9c7d9aafec 100644
--- a/services/repository/files/temp_repo.go
+++ b/services/repository/files/temp_repo.go
@@ -19,6 +19,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
+ repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
asymkey_service "code.gitea.io/gitea/services/asymkey"
"code.gitea.io/gitea/services/gitdiff"
@@ -34,7 +35,7 @@ type TemporaryUploadRepository struct {
// NewTemporaryUploadRepository creates a new temporary upload repository
func NewTemporaryUploadRepository(ctx context.Context, repo *repo_model.Repository) (*TemporaryUploadRepository, error) {
- basePath, err := models.CreateTemporaryPath("upload")
+ basePath, err := repo_module.CreateTemporaryPath("upload")
if err != nil {
return nil, err
}
@@ -45,7 +46,7 @@ func NewTemporaryUploadRepository(ctx context.Context, repo *repo_model.Reposito
// Close the repository cleaning up all files
func (t *TemporaryUploadRepository) Close() {
defer t.gitRepo.Close()
- if err := models.RemoveTemporaryPath(t.basePath); err != nil {
+ if err := repo_module.RemoveTemporaryPath(t.basePath); err != nil {
log.Error("Failed to remove temporary path %s: %v", t.basePath, err)
}
}
@@ -315,7 +316,7 @@ func (t *TemporaryUploadRepository) CommitTreeWithDate(parent string, author, co
// Push the provided commitHash to the repository branch by the provided user
func (t *TemporaryUploadRepository) Push(doer *user_model.User, commitHash, branch string) error {
// Because calls hooks we need to pass in the environment
- env := models.PushingEnvironment(doer, t.repo)
+ env := repo_module.PushingEnvironment(doer, t.repo)
if err := git.Push(t.ctx, t.basePath, git.PushOptions{
Remote: t.repo.RepoPath(),
Branch: strings.TrimSpace(commitHash) + ":" + git.BranchPrefix + strings.TrimSpace(branch),