File: patterns.go

package info (click to toggle)
golang-github-monochromegane-go-gitignore 0.0~git20200626.205db1a-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 108 kB
  • sloc: makefile: 2
file content (22 lines) | stat: -rw-r--r-- 388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package gitignore

type patterns struct {
	patterns []pattern
}

func (ps *patterns) add(pattern pattern) {
	ps.patterns = append(ps.patterns, pattern)
}

func (ps *patterns) size() int {
	return len(ps.patterns)
}

func (ps patterns) match(path string, isDir bool) bool {
	for _, p := range ps.patterns {
		if match := p.match(path, isDir); match {
			return true
		}
	}
	return false
}