summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-12 10:21:13 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-02-12 18:12:01 +1100
commit7a3291a1f78977cff6372f81e044675e88b25d46 (patch)
treee7b37a689d744718c7d26317d351f8ac979149f9
parent08c2b46d0498926d928d02da7f1c3cbf35aceec6 (diff)
fix test
-rw-r--r--pkg/integration/components/runner.go28
-rw-r--r--test/global_git_config8
2 files changed, 24 insertions, 12 deletions
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