github.com/andrewrech/lazygit@v0.8.1/pkg/test/test.go (about) 1 package test 2 3 import ( 4 "github.com/go-errors/errors" 5 "os" 6 "os/exec" 7 "path/filepath" 8 9 "github.com/jesseduffield/lazygit/pkg/utils" 10 ) 11 12 // GenerateRepo generates a repo from test/repos and changes the directory to be 13 // inside the newly made repo 14 func GenerateRepo(filename string) error { 15 reposDir := "/test/repos/" 16 testPath := utils.GetProjectRoot() + reposDir 17 18 // workaround for debian packaging 19 if _, err := os.Stat(testPath); os.IsNotExist(err) { 20 cwd, _ := os.Getwd() 21 testPath = filepath.Dir(filepath.Dir(cwd)) + reposDir 22 } 23 if err := os.Chdir(testPath); err != nil { 24 return err 25 } 26 if output, err := exec.Command("bash", filename).CombinedOutput(); err != nil { 27 return errors.New(string(output)) 28 } 29 30 return os.Chdir(testPath + "repo") 31 }