From 4ec6f48e3e55a8094d51dcb13762240143bff3ab Mon Sep 17 00:00:00 2001 From: Jefferson Ramos Date: Fri, 13 Sep 2024 09:57:26 -0300 Subject: [PATCH] test: preventing dubios ownership repository error on git unit tests --- pkg/testing/testing.go | 7 +++++++ 1 file changed, 7 insertions(+) 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) }