diff --git a/pkg/testing/testing.go b/pkg/testing/testing.go index 9853dac9cb..f953b7d26b 100644 --- a/pkg/testing/testing.go +++ b/pkg/testing/testing.go @@ -143,6 +143,13 @@ func ServeRepo(name string, t *testing.T) string { repo = filepath.Base(path) url = RunGitServer(abs, t) ) + // This is to prevent "fatal: detected dubious ownership in repository at " while executing + // unit tests on other environments (such as Prow CI) + cmd := exec.Command("git", "config", "--global", "--add", "safe.directory", abs) + _, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } return fmt.Sprintf("%v/%v", url, repo) }