diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go index 2b05d102e..394ac00df 100644 --- a/pkg/integration/components/runner.go +++ b/pkg/integration/components/runner.go @@ -14,8 +14,9 @@ import ( // this is the integration runner for the new and improved integration interface const ( - TEST_NAME_ENV_VAR = "TEST_NAME" - SANDBOX_ENV_VAR = "SANDBOX" + TEST_NAME_ENV_VAR = "TEST_NAME" + SANDBOX_ENV_VAR = "SANDBOX" + GIT_CONFIG_GLOBAL_ENV_VAR = "GIT_CONFIG_GLOBAL" ) func RunTests( @@ -82,7 +83,7 @@ func runTest( logf("path: %s", paths.Root()) - if err := prepareTestDir(test, paths); err != nil { + if err := prepareTestDir(test, paths, projectRootDir); err != nil { return err } @@ -102,6 +103,7 @@ func runTest( func prepareTestDir( test *IntegrationTest, paths Paths, + rootDir string, ) error { findOrCreateDir(paths.Root()) deleteAndRecreateEmptyDir(paths.Actual()) @@ -111,7 +113,7 @@ func prepareTestDir( return err } - return createFixture(test, paths) + return createFixture(test, paths, rootDir) } func buildLazygit() error { @@ -125,28 +127,30 @@ func buildLazygit() error { )).Run() } -func createFixture(test *IntegrationTest, paths Paths) error { +func createFixture(test *IntegrationTest, paths Paths, rootDir string) error { shell := NewShell(paths.ActualRepo(), func(errorMsg string) { panic(errorMsg) }) shell.RunCommand("git init -b master") - shell.RunCommand(`git config user.email "CI@example.com"`) - shell.RunCommand(`git config user.name "CI"`) - shell.RunCommand(`git config commit.gpgSign false`) - shell.RunCommand(`git config protocol.file.allow always`) + + os.Setenv(GIT_CONFIG_GLOBAL_ENV_VAR, globalGitConfigPath(rootDir)) test.SetupRepo(shell) return nil } +func globalGitConfigPath(rootDir string) string { + return filepath.Join(rootDir, "test", "global_git_config") +} + func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandbox bool, keyPressDelay int) (*exec.Cmd, error) { osCommand := oscommands.NewDummyOSCommand() - templateConfigDir := filepath.Join(rootDir, "test", "default_test_config") - err := os.RemoveAll(paths.Config()) if err != nil { return nil, err } + + templateConfigDir := filepath.Join(rootDir, "test", "default_test_config") err = oscommands.CopyDir(templateConfigDir, paths.Config()) if err != nil { return nil, err @@ -165,7 +169,7 @@ func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandb cmdObj.AddEnvVars(fmt.Sprintf("KEY_PRESS_DELAY=%d", keyPressDelay)) } - cmdObj.AddEnvVars("GIT_CONFIG_GLOBAL=/dev/null") + cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", GIT_CONFIG_GLOBAL_ENV_VAR, globalGitConfigPath(rootDir))) return cmdObj.GetCmd(), nil } diff --git a/test/global_git_config b/test/global_git_config new file mode 100644 index 000000000..bfd11875c --- /dev/null +++ b/test/global_git_config @@ -0,0 +1,8 @@ +[user] + name = CI + email = CI@example.com +[protocol "file"] + # see https://vielmetti.typepad.com/logbook/2022/10/git-security-fixes-lead-to-fatal-transport-file-not-allowed-error-in-ci-systems-cve-2022-39253.html + allow = always +[commit] + gpgSign = false