-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathignore.go
More file actions
49 lines (38 loc) · 782 Bytes
/
ignore.go
File metadata and controls
49 lines (38 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"path/filepath"
"strings"
)
func (cfg *config) ignore(path string) string {
if cfg.matchesBases(path) {
return "bases"
}
if cfg.matchesContains(path) {
return "contains"
}
if cfg.matchesRegexes(path) {
return "regexes"
}
return ""
}
func (cfg *config) matchesBases(path string) bool {
base := filepath.Base(path)
_, ok := cfg.ignoreBasesMap[base]
return ok
}
func (cfg *config) matchesContains(path string) bool {
for _, s := range cfg.ignoreContainsList {
if strings.Contains(strings.ToUpper(path), strings.ToUpper(s)) {
return true
}
}
return false
}
func (cfg *config) matchesRegexes(path string) bool {
for _, re := range cfg.ignoreRegexesCompiled {
if re.MatchString(path) {
return true
}
}
return false
}