(repoRoot, subpath string)
| 209 | } |
| 210 | |
| 211 | func 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. |
no test coverage detected