mirror of https://github.com/k3s-io/k3s
32 lines
601 B
Go
32 lines
601 B
Go
package gitignore
|
|
|
|
import "strings"
|
|
|
|
// Only benchmark use
|
|
type fullScanPatterns struct {
|
|
absolute patterns
|
|
relative patterns
|
|
}
|
|
|
|
func newFullScanPatterns() *fullScanPatterns {
|
|
return &fullScanPatterns{
|
|
absolute: patterns{},
|
|
relative: patterns{},
|
|
}
|
|
}
|
|
|
|
func (ps *fullScanPatterns) add(pattern string) {
|
|
if strings.HasPrefix(pattern, "/") {
|
|
ps.absolute.add(newPattern(pattern))
|
|
} else {
|
|
ps.relative.add(newPattern(pattern))
|
|
}
|
|
}
|
|
|
|
func (ps fullScanPatterns) match(path string, isDir bool) bool {
|
|
if ps.absolute.match(path, isDir) {
|
|
return true
|
|
}
|
|
return ps.relative.match(path, isDir)
|
|
}
|