(fileSystem afero.Fs, path, ignore string)
| 40 | } |
| 41 | |
| 42 | func readIgnoreFile(fileSystem afero.Fs, path, ignore string) ([]gitignore.Pattern, error) { |
| 43 | var ps []gitignore.Pattern |
| 44 | |
| 45 | data, err := afero.ReadFile(fileSystem, filepath.Join(path, ignore)) |
| 46 | if err != nil && !errors.Is(err, os.ErrNotExist) { |
| 47 | return nil, err |
| 48 | } |
| 49 | |
| 50 | for s := range strings.SplitSeq(string(data), "\n") { |
| 51 | if !strings.HasPrefix(s, "#") && len(strings.TrimSpace(s)) > 0 { |
| 52 | ps = append(ps, gitignore.ParsePattern(s, FilePathToParts(path))) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return ps, nil |
| 57 | } |
| 58 | |
| 59 | func ReadPatterns(ctx context.Context, logger slog.Logger, fileSystem afero.Fs, path string) ([]gitignore.Pattern, error) { |
| 60 | var ps []gitignore.Pattern |
no test coverage detected