(ctx context.Context, logger slog.Logger, fileSystem afero.Fs, path string)
| 57 | } |
| 58 | |
| 59 | func ReadPatterns(ctx context.Context, logger slog.Logger, fileSystem afero.Fs, path string) ([]gitignore.Pattern, error) { |
| 60 | var ps []gitignore.Pattern |
| 61 | |
| 62 | subPs, err := readIgnoreFile(fileSystem, path, gitInfoExcludeFile) |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | |
| 67 | ps = append(ps, subPs...) |
| 68 | |
| 69 | if err := afero.Walk(fileSystem, path, func(path string, info fs.FileInfo, err error) error { |
| 70 | if err != nil { |
| 71 | logger.Error(ctx, "encountered error while walking for git ignore files", |
| 72 | slog.F("path", path), |
| 73 | slog.Error(err)) |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | if !info.IsDir() { |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | subPs, err := readIgnoreFile(fileSystem, path, gitignoreFile) |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | |
| 86 | ps = append(ps, subPs...) |
| 87 | |
| 88 | return nil |
| 89 | }); err != nil { |
| 90 | return nil, err |
| 91 | } |
| 92 | |
| 93 | return ps, nil |
| 94 | } |
| 95 | |
| 96 | func loadPatterns(fileSystem afero.Fs, path string) ([]gitignore.Pattern, error) { |
| 97 | data, err := afero.ReadFile(fileSystem, path) |
no test coverage detected