Fix integration tests (#3141)

This commit is contained in:
Ethan Koenig 2017-12-10 16:52:05 -08:00 committed by Bo-Yi Wu
parent 41d6afe0e7
commit d1efe2078a
2 changed files with 10 additions and 4 deletions

View File

@ -136,6 +136,7 @@ func initIntegrationTest() {
func prepareTestEnv(t testing.TB) { func prepareTestEnv(t testing.TB) {
assert.NoError(t, models.LoadFixtures()) assert.NoError(t, models.LoadFixtures())
assert.NoError(t, os.RemoveAll(setting.RepoRootPath)) 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"), assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"),
setting.RepoRootPath)) setting.RepoRootPath))

View File

@ -757,12 +757,17 @@ func (repo *Repository) DescriptionHTML() template.HTML {
return template.HTML(descPattern.ReplaceAllStringFunc(markup.Sanitize(repo.Description), sanitize)) return template.HTML(descPattern.ReplaceAllStringFunc(markup.Sanitize(repo.Description), sanitize))
} }
// LocalCopyPath returns the local repository copy path // LocalCopyPath returns the local repository copy path.
func (repo *Repository) LocalCopyPath() string { func LocalCopyPath() string {
if filepath.IsAbs(setting.Repository.Local.LocalCopyPath) { 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. // UpdateLocalCopyBranch pulls latest changes of given branch from repoPath to localPath.