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

Function isGitIgnored

cli/pkg/gitutil/gitcmdwrapper.go:211–228  ·  view source on GitHub ↗
(repoRoot, subpath string)

Source from the content-addressed store, hash-verified

209}
210
211func isGitIgnored(repoRoot, subpath string) (bool, error) {
212 cmd := exec.Command("git", "-C", repoRoot, "check-ignore", subpath)
213 err := cmd.Run()
214 if err != nil {
215 var execErr *exec.ExitError
216 if errors.As(err, &execErr) {
217 // exit code 1 means the file is not ignored
218 if execErr.ExitCode() == 1 {
219 return false, nil
220 }
221 // any other exit code is an error
222 return false, fmt.Errorf("git check-ignore failed for path %q, subpath: %q : %s", repoRoot, subpath, string(execErr.Stderr))
223 }
224 return false, fmt.Errorf("git check-ignore failed for path %q, subpath %q: %w", repoRoot, subpath, err)
225 }
226 // exit code 0 means the file is ignored
227 return true, nil
228}
229
230// countAheadBehind returns the number of non-merge commits on `local` not in `remote` (ahead)
231// and on `remote` not in `local` (behind), in a single git invocation.

Callers 1

InferRepoRootAndSubpathFunction · 0.85

Calls 2

ErrorfMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected