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

Function absPatterns

pkg/watch/dockerignore.go:101–128  ·  view source on GitHub ↗

Make all the patterns use absolute paths.

(absRoot string, patterns []string)

Source from the content-addressed store, hash-verified

99
100// Make all the patterns use absolute paths.
101func absPatterns(absRoot string, patterns []string) []string {
102 absPatterns := make([]string, 0, len(patterns))
103 for _, p := range patterns {
104 // The pattern parsing here is loosely adapted from fileutils' NewPatternMatcher
105 p = strings.TrimSpace(p)
106 if p == "" {
107 continue
108 }
109 p = filepath.Clean(p)
110
111 pPath := p
112 isExclusion := false
113 if p[0] == '!' {
114 pPath = p[1:]
115 isExclusion = true
116 }
117
118 if !filepath.IsAbs(pPath) {
119 pPath = filepath.Join(absRoot, pPath)
120 }
121 absPattern := pPath
122 if isExclusion {
123 absPattern = fmt.Sprintf("!%s", pPath)
124 }
125 absPatterns = append(absPatterns, absPattern)
126 }
127 return absPatterns
128}
129
130func NewDockerPatternMatcher(repoRoot string, patterns []string) (*dockerPathMatcher, error) {
131 absRoot, err := filepath.Abs(repoRoot)

Callers 1

NewDockerPatternMatcherFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected