mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-21 21:48:00 +02:00
Remove hardcoded paths to fix randomly failing tests (#3347)
* Remove hardcoded paths to fix randomly failing tests * Use correct function for merge path
This commit is contained in:

committed by
Kim "BKC" Carlbäcker

parent
d8dff304c0
commit
be1330ec89
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user