File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 44package gitrepo
55
66import (
7+ "fmt"
78 "os"
89 "path/filepath"
910 "testing"
1011
1112 "code.gitea.io/gitea/modules/setting"
13+ "code.gitea.io/gitea/modules/util"
1214)
1315
1416const (
1517 testReposDir = "../git/tests/repos/"
1618)
1719
1820func TestMain (m * testing.M ) {
21+ // since all test repository is defined by testReposDir, we need to set it here
22+ // So that all functions could work properly because Repository will only contain
23+ // Relative Path to RepoRootPath
1924 setting .RepoRootPath , _ = filepath .Abs (testReposDir )
20- setting .Git .HomePath = filepath .Join (setting .RepoRootPath , ".home" )
25+ // TODO: run command requires a home directory, we could set it to a temp dir
26+ gitHomePath , err := os .MkdirTemp (os .TempDir (), "git-home" )
27+ if err != nil {
28+ panic (fmt .Errorf ("unable to create temp dir: %w" , err ))
29+ }
30+ defer util .RemoveAll (gitHomePath )
31+ setting .Git .HomePath = gitHomePath
2132
2233 exitStatus := m .Run ()
2334 os .Exit (exitStatus )
You can’t perform that action at this time.
0 commit comments