MCPcopy Index your code
hub / github.com/nikivdev/go / findGitRoot

Function findGitRoot

cli/spec/main.go:1109–1124  ·  view source on GitHub ↗
(start string)

Source from the content-addressed store, hash-verified

1107}
1108
1109func findGitRoot(start string) string {
1110 dir := start
1111 for {
1112 if dir == "" || dir == "/" || dir == "." {
1113 return ""
1114 }
1115 if fileExists(filepath.Join(dir, ".git")) {
1116 return dir
1117 }
1118 next := filepath.Dir(dir)
1119 if next == dir {
1120 return ""
1121 }
1122 dir = next
1123 }
1124}
1125
1126func fileExists(path string) bool {
1127 _, err := os.Stat(path)

Callers 1

buildPromptBundleFunction · 0.85

Calls 1

fileExistsFunction · 0.85

Tested by

no test coverage detected