diff --git a/test/pkg/integration/common/git-client.go b/test/pkg/integration/common/git-client.go index 75163e5cd2632f..4cf39291b74f47 100644 --- a/test/pkg/integration/common/git-client.go +++ b/test/pkg/integration/common/git-client.go @@ -58,6 +58,22 @@ func (g GitClient) Add(dir string, files ...string) error { return nil } +func (g GitClient) ConfigSafeDirectory(dir string) error { + var resp agent.ExecResponse + err := g.Call("WorkspaceAgent.Exec", &agent.ExecRequest{ + Dir: dir, + Command: "git", + Args: []string{"config", "--global", "--add", "safe.directory", dir}, + }, &resp) + if err != nil { + return err + } + if resp.ExitCode != 0 { + return fmt.Errorf("config returned rc: %d err: %v", resp.ExitCode, resp.Stderr) + } + return nil +} + func (g GitClient) ConfigUserName(dir string) error { args := []string{"config", "--local", "user.name", "integration-test"} var resp agent.ExecResponse diff --git a/test/tests/workspace/contexts_test.go b/test/tests/workspace/contexts_test.go index 5ac5c3cd346ffc..b3b6e4cbee2356 100644 --- a/test/tests/workspace/contexts_test.go +++ b/test/tests/workspace/contexts_test.go @@ -143,6 +143,10 @@ func runContextTests(t *testing.T, tests []ContextTest) { // get actual from workspace git := common.Git(rsa) + err = git.ConfigSafeDirectory(test.WorkspaceRoot) + if err != nil { + t.Fatal(err) + } actBranch, err := git.GetBranch(test.WorkspaceRoot) if err != nil { t.Fatal(err) diff --git a/test/tests/workspace/git_test.go b/test/tests/workspace/git_test.go index cfd0afe5882ac9..bb2565e42d7b07 100644 --- a/test/tests/workspace/git_test.go +++ b/test/tests/workspace/git_test.go @@ -41,7 +41,6 @@ func TestGitActions(t *testing.T) { ContextURL: "github.com/gitpod-io/gitpod-test-repo/tree/integration-test/commit-and-push", WorkspaceRoot: "/workspace/gitpod-test-repo", Action: func(rsa *rpc.Client, git common.GitClient, workspaceRoot string) (err error) { - var resp agent.ExecResponse err = rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{ Dir: workspaceRoot, @@ -54,6 +53,10 @@ func TestGitActions(t *testing.T) { if err != nil { return err } + err = git.ConfigSafeDirectory(workspaceRoot) + if err != nil { + return err + } err = git.ConfigUserName(workspaceRoot) if err != nil { return err @@ -79,7 +82,6 @@ func TestGitActions(t *testing.T) { ContextURL: "github.com/gitpod-io/gitpod-test-repo/tree/integration-test/commit-and-push", WorkspaceRoot: "/workspace/gitpod-test-repo", Action: func(rsa *rpc.Client, git common.GitClient, workspaceRoot string) (err error) { - var resp agent.ExecResponse err = rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{ Dir: workspaceRoot, @@ -92,6 +94,10 @@ func TestGitActions(t *testing.T) { if err != nil { return err } + err = git.ConfigSafeDirectory(workspaceRoot) + if err != nil { + return err + } err = git.ConfigUserName(workspaceRoot) if err != nil { return err