MCPcopy Create free account
hub / github.com/go-task/task / Match

Method Match

internal/gitignore/pattern.go:78–100  ·  view source on GitHub ↗
(path []string, isDir bool)

Source from the content-addressed store, hash-verified

76}
77
78func (p *pattern) Match(path []string, isDir bool) MatchResult {
79 if len(path) <= len(p.domain) {
80 return NoMatch
81 }
82 for i, e := range p.domain {
83 if path[i] != e {
84 return NoMatch
85 }
86 }
87
88 path = path[len(p.domain):]
89 if p.isGlob && !p.globMatch(path, isDir) {
90 return NoMatch
91 } else if !p.isGlob && !p.simpleNameMatch(path, isDir) {
92 return NoMatch
93 }
94
95 if p.inclusion {
96 return Include
97 } else {
98 return Exclude
99 }
100}
101
102func (p *pattern) simpleNameMatch(path []string, isDir bool) bool {
103 for i, name := range path {

Callers

nothing calls this directly

Calls 2

globMatchMethod · 0.95
simpleNameMatchMethod · 0.95

Tested by

no test coverage detected