1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-21 21:47:32 +02:00
This commit is contained in:
Jesse Duffield 2023-02-12 10:21:13 +11:00
parent 08c2b46d04
commit 7a3291a1f7
2 changed files with 24 additions and 12 deletions
pkg/integration/components
test

@ -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
}

8
test/global_git_config Normal file

@ -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