From d1efe2078a07f74db3f3ce6c33cf0a7da0dec18a Mon Sep 17 00:00:00 2001 From: Ethan Koenig Date: Sun, 10 Dec 2017 16:52:05 -0800 Subject: [PATCH] Fix integration tests (#3141) --- integrations/integration_test.go | 1 + models/repo.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/integrations/integration_test.go b/integrations/integration_test.go index ee0b1a88682..f9e0d5f13c0 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -136,6 +136,7 @@ func initIntegrationTest() { func prepareTestEnv(t testing.TB) { assert.NoError(t, models.LoadFixtures()) assert.NoError(t, os.RemoveAll(setting.RepoRootPath)) + assert.NoError(t, os.RemoveAll(models.LocalCopyPath())) assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath)) diff --git a/models/repo.go b/models/repo.go index 3142b324f1b..77a960deb77 100644 --- a/models/repo.go +++ b/models/repo.go @@ -757,12 +757,17 @@ func (repo *Repository) DescriptionHTML() template.HTML { return template.HTML(descPattern.ReplaceAllStringFunc(markup.Sanitize(repo.Description), sanitize)) } -// LocalCopyPath returns the local repository copy path -func (repo *Repository) LocalCopyPath() string { +// LocalCopyPath returns the local repository copy path. +func LocalCopyPath() string { if filepath.IsAbs(setting.Repository.Local.LocalCopyPath) { - return path.Join(setting.Repository.Local.LocalCopyPath, com.ToStr(repo.ID)) + return setting.Repository.Local.LocalCopyPath } - return path.Join(setting.AppDataPath, setting.Repository.Local.LocalCopyPath, com.ToStr(repo.ID)) + return path.Join(setting.AppDataPath, setting.Repository.Local.LocalCopyPath) +} + +// LocalCopyPath returns the local repository copy path for the given repo. +func (repo *Repository) LocalCopyPath() string { + return path.Join(LocalCopyPath(), com.ToStr(repo.ID)) } // UpdateLocalCopyBranch pulls latest changes of given branch from repoPath to localPath.