mirror of https://github.com/helm/helm
Signed-off-by: Danilo Patrucco <danilo.patrucco@gmail.com>pull/13205/head
parent
1eaae6de39
commit
ac283a5587
@ -0,0 +1,23 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func IsIgnored(path string, patterns []string) bool {
|
||||||
|
for _, pattern := range patterns {
|
||||||
|
cleanedPath := filepath.Clean(path)
|
||||||
|
cleanedPattern := filepath.Clean(pattern)
|
||||||
|
if match, err := filepath.Match(cleanedPattern, cleanedPath); err == nil && match {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if strings.HasSuffix(cleanedPattern, "/") || strings.HasSuffix(cleanedPattern, "\\") {
|
||||||
|
patternDir := strings.TrimRight(cleanedPattern, "/\\")
|
||||||
|
if strings.HasPrefix(cleanedPath, patternDir) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
Loading…
Reference in new issue