MCPcopy Index your code
hub / github.com/go-task/task / findRepoRoot

Function findRepoRoot

internal/fingerprint/gitignore.go:27–48  ·  view source on GitHub ↗

findRepoRoot returns the first ancestor of dir containing a .git entry, or ("", false) when dir is not inside a git repository.

(dir string)

Source from the content-addressed store, hash-verified

25// findRepoRoot returns the first ancestor of dir containing a .git entry, or
26// ("", false) when dir is not inside a git repository.
27func findRepoRoot(dir string) (string, bool) {
28 if v, ok := repoRootCache.Load(dir); ok {
29 root := v.(string)
30 return root, root != ""
31 }
32
33 current := dir
34 for {
35 if _, err := os.Stat(filepath.Join(current, ".git")); err == nil {
36 repoRootCache.Store(dir, current)
37 return current, true
38 }
39 parent := filepath.Dir(current)
40 if parent == current {
41 break
42 }
43 current = parent
44 }
45
46 repoRootCache.Store(dir, "")
47 return "", false
48}
49
50// filterGitignored marks entries matching gitignore rules as excluded (false).
51// All .gitignore files from the repo root down to each candidate file's

Callers 1

filterGitignoredFunction · 0.85

Calls 1

DirMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…