...
1 package gitignore
2
3 import "strings"
4
5 type indexScanPatterns struct {
6 absolute depthPatternHolder
7 relative depthPatternHolder
8 }
9
10 func newIndexScanPatterns() *indexScanPatterns {
11 return &indexScanPatterns{
12 absolute: newDepthPatternHolder(asc),
13 relative: newDepthPatternHolder(desc),
14 }
15 }
16
17 func (ps *indexScanPatterns) add(pattern string) {
18 if strings.HasPrefix(pattern, "/") {
19 ps.absolute.add(pattern)
20 } else {
21 ps.relative.add(pattern)
22 }
23 }
24
25 func (ps indexScanPatterns) match(path string, isDir bool) bool {
26 if ps.absolute.match(path, isDir) {
27 return true
28 }
29 return ps.relative.match(path, isDir)
30 }
31
32 type scanStrategy interface {
33 add(pattern string)
34 match(path string, isDir bool) bool
35 }
36
View as plain text