MCPcopy Create free account
hub / github.com/github/gh-aw / findRepoRoot

Function findRepoRoot

pkg/parser/frontmatter_hash_cross_language_test.go:318–335  ·  view source on GitHub ↗

findRepoRoot finds the repository root directory

(t *testing.T)

Source from the content-addressed store, hash-verified

316
317// findRepoRoot finds the repository root directory
318func 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}

Calls

no outgoing calls

Tested by

no test coverage detected