MCPcopy Index your code
hub / github.com/rilldata/rill / InferGitRepoRoot

Function InferGitRepoRoot

cli/pkg/gitutil/gitcmdwrapper.go:194–209  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

192}
193
194func InferGitRepoRoot(path string) (string, error) {
195 cmd := exec.Command("git", "-C", path, "rev-parse", "--show-cdup")
196 data, err := cmd.Output()
197 if err != nil {
198 var execErr *exec.ExitError
199 if !errors.As(err, &execErr) {
200 return "", err
201 }
202 errStr := strings.TrimSpace(string(execErr.Stderr))
203 if strings.Contains(errStr, "not a git repository") {
204 return "", ErrNotAGitRepository
205 }
206 return "", errors.New(string(execErr.Stderr))
207 }
208 return filepath.Join(path, strings.TrimSpace(string(data))), nil
209}
210
211func isGitIgnored(repoRoot, subpath string) (bool, error) {
212 cmd := exec.Command("git", "-C", repoRoot, "check-ignore", subpath)

Calls 1

ContainsMethod · 0.80