MCPcopy
hub / github.com/docker/compose / NewDockerPatternMatcher

Function NewDockerPatternMatcher

pkg/watch/dockerignore.go:130–154  ·  view source on GitHub ↗
(repoRoot string, patterns []string)

Source from the content-addressed store, hash-verified

128}
129
130func NewDockerPatternMatcher(repoRoot string, patterns []string) (*dockerPathMatcher, error) {
131 absRoot, err := filepath.Abs(repoRoot)
132 if err != nil {
133 return nil, err
134 }
135
136 // Check if "*" is present in patterns
137 hasAllPattern := slices.Contains(patterns, "*")
138 if hasAllPattern {
139 // Remove all non-exclusion patterns (those that don't start with '!')
140 patterns = slices.DeleteFunc(patterns, func(p string) bool {
141 return p != "" && p[0] != '!' // Only keep exclusion patterns
142 })
143 }
144
145 pm, err := patternmatcher.New(absPatterns(absRoot, patterns))
146 if err != nil {
147 return nil, err
148 }
149
150 return &dockerPathMatcher{
151 repoRoot: absRoot,
152 matcher: pm,
153 }, nil
154}
155
156func readDockerignorePatterns(r io.Reader) ([]string, error) {
157 patterns, err := ignorefile.ReadAll(r)

Callers 6

getWatchRulesFunction · 0.92
initialSyncMethod · 0.92
LoadDockerIgnoreFunction · 0.85
EphemeralPathMatcherFunction · 0.85

Calls 1

absPatternsFunction · 0.85

Tested by 1