MCPcopy Index your code
hub / github.com/coder/coder / ReadPatterns

Function ReadPatterns

agent/agentcontainers/ignore/dir.go:59–94  ·  view source on GitHub ↗
(ctx context.Context, logger slog.Logger, fileSystem afero.Fs, path string)

Source from the content-addressed store, hash-verified

57}
58
59func 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
96func loadPatterns(fileSystem afero.Fs, path string) ([]gitignore.Pattern, error) {
97 data, err := afero.ReadFile(fileSystem, path)

Callers 1

Calls 2

readIgnoreFileFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected