findRepoRoot finds the repository root directory
(t *testing.T)
| 316 | |
| 317 | // findRepoRoot finds the repository root directory |
| 318 | func findRepoRoot(t *testing.T) string { |
| 319 | // Start from current directory and walk up to find .git |
| 320 | dir, err := os.Getwd() |
| 321 | require.NoError(t, err, "Should get current directory") |
| 322 | |
| 323 | for { |
| 324 | gitDir := filepath.Join(dir, ".git") |
| 325 | if _, err := os.Stat(gitDir); err == nil { |
| 326 | return dir |
| 327 | } |
| 328 | |
| 329 | parent := filepath.Dir(dir) |
| 330 | if parent == dir { |
| 331 | t.Fatal("Could not find repository root") |
| 332 | } |
| 333 | dir = parent |
| 334 | } |
| 335 | } |
no outgoing calls
no test coverage detected