Fix unnecessary changes

This commit is contained in:
Lunny Xiao 2024-10-27 16:01:40 -07:00
parent 7b0f3e6473
commit fc25971f57
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
4 changed files with 9 additions and 6 deletions

View File

@ -15,7 +15,6 @@ import (
"path/filepath"
"strings"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
)
@ -33,7 +32,7 @@ func main() {
flag.StringVar(&githubApiToken, "token", "", "github api token")
flag.Parse()
file, err := os.CreateTemp(setting.TempDir(), prefix)
file, err := os.CreateTemp(os.TempDir(), prefix)
if err != nil {
log.Fatalf("Failed to create temp file. %s", err)
}

View File

@ -22,7 +22,6 @@ import (
"code.gitea.io/gitea/build/license"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
)
@ -40,7 +39,7 @@ func main() {
flag.StringVar(&githubApiToken, "token", "", "github api token")
flag.Parse()
file, err := os.CreateTemp(setting.TempDir(), prefix)
file, err := os.CreateTemp(os.TempDir(), prefix)
if err != nil {
log.Fatalf("Failed to create temp file. %s", err)
}

View File

@ -15,7 +15,12 @@ import (
// localCopyPath returns the local repository temporary copy path.
func localCopyPath() string {
return filepath.Join(setting.TempDir(), "local-repo")
if setting.Repository.Local.LocalCopyPath == "" {
return filepath.Join(os.TempDir(), "local-repo")
} else if !filepath.IsAbs(setting.Repository.Local.LocalCopyPath) {
return filepath.Join(os.TempDir(), setting.Repository.Local.LocalCopyPath)
}
return setting.Repository.Local.LocalCopyPath
}
func CleanUpTemporaryPaths() {

View File

@ -78,7 +78,7 @@ func InitTest(requireGitea bool) {
unittest.InitSettings()
setting.Repository.DefaultBranch = "master" // many test code still assume that default branch is called "master"
_ = util.RemoveAll(repo_module.LocalCopyPath())
repo_module.CleanUpTemporaryPaths()
if err := git.InitFull(context.Background()); err != nil {
log.Fatal("git.InitOnceWithSync: %v", err)