test: preventing dubios ownership repository error on git unit tests (#2499)

This commit is contained in:
Jefferson Ramos 2024-09-13 10:33:35 -03:00 committed by GitHub
parent 81169a4d80
commit 84f4caf724
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -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 <source_reposutory_path>" 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)
}