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

Function readIgnoreFile

agent/agentcontainers/ignore/dir.go:42–57  ·  view source on GitHub ↗
(fileSystem afero.Fs, path, ignore string)

Source from the content-addressed store, hash-verified

40}
41
42func 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
59func ReadPatterns(ctx context.Context, logger slog.Logger, fileSystem afero.Fs, path string) ([]gitignore.Pattern, error) {
60 var ps []gitignore.Pattern

Callers 2

ReadPatternsFunction · 0.85
loadPatternsFunction · 0.85

Calls 3

FilePathToPartsFunction · 0.85
ReadFileMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected