diff options
author | Lauris BH <lauris@nix.lv> | 2018-01-11 01:46:59 +0200 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2018-01-11 00:46:59 +0100 |
commit | be1330ec89308f76557bd7fc708b1f16c703f429 (patch) | |
tree | abdcd377f6be772aa38e9840b683e09f52a5d5c4 /models | |
parent | d8dff304c0a6abb471051e968f6bdb69679b9a2a (diff) | |
download | gitea-be1330ec89308f76557bd7fc708b1f16c703f429.tar.gz gitea-be1330ec89308f76557bd7fc708b1f16c703f429.zip |
Remove hardcoded paths to fix randomly failing tests (#3347)
* Remove hardcoded paths to fix randomly failing tests
* Use correct function for merge path
Diffstat (limited to 'models')
-rw-r--r-- | models/pull.go | 2 | ||||
-rw-r--r-- | models/wiki.go | 10 | ||||
-rw-r--r-- | models/wiki_test.go | 2 |
3 files changed, 11 insertions, 3 deletions
diff --git a/models/pull.go b/models/pull.go index c9357e9130..38312e4e40 100644 --- a/models/pull.go +++ b/models/pull.go @@ -299,7 +299,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle } // Clone base repo. - tmpBasePath := path.Join(setting.AppDataPath, "tmp/repos", com.ToStr(time.Now().Nanosecond())+".git") + tmpBasePath := path.Join(LocalCopyPath(), "merge-"+com.ToStr(time.Now().Nanosecond())+".git") if err := os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm); err != nil { return fmt.Errorf("Failed to create dir %s: %v", tmpBasePath, err) diff --git a/models/wiki.go b/models/wiki.go index 3819eb95f0..3a39daf0f6 100644 --- a/models/wiki.go +++ b/models/wiki.go @@ -90,9 +90,17 @@ func (repo *Repository) InitWiki() error { return nil } +// LocalWikiPath returns the local wiki repository copy path. +func LocalWikiPath() string { + if filepath.IsAbs(setting.Repository.Local.LocalWikiPath) { + return setting.Repository.Local.LocalWikiPath + } + return path.Join(setting.AppDataPath, setting.Repository.Local.LocalWikiPath) +} + // LocalWikiPath returns the path to the local wiki repository (?). func (repo *Repository) LocalWikiPath() string { - return path.Join(setting.AppDataPath, "tmp/local-wiki", com.ToStr(repo.ID)) + return path.Join(LocalWikiPath(), com.ToStr(repo.ID)) } // UpdateLocalWiki makes sure the local copy of repository wiki is up-to-date. diff --git a/models/wiki_test.go b/models/wiki_test.go index c816a17558..80f6df55ec 100644 --- a/models/wiki_test.go +++ b/models/wiki_test.go @@ -145,7 +145,7 @@ func TestRepository_InitWiki(t *testing.T) { func TestRepository_LocalWikiPath(t *testing.T) { PrepareTestEnv(t) repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) - expected := filepath.Join(setting.AppDataPath, "tmp/local-wiki/1") + expected := filepath.Join(setting.AppDataPath, setting.Repository.Local.LocalWikiPath, "1") assert.Equal(t, expected, repo.LocalWikiPath()) } |