mirror of https://github.com/helm/helm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
763 B
26 lines
763 B
package rules
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
"fmt"
|
|
)
|
|
|
|
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 {
|
|
fmt.Printf("Ignoring path: %s due to pattern: %s\n", path, pattern)
|
|
return true
|
|
}
|
|
if strings.HasSuffix(cleanedPattern, "/") || strings.HasSuffix(cleanedPattern, "\\") {
|
|
patternDir := strings.TrimRight(cleanedPattern, "/\\")
|
|
if strings.HasPrefix(cleanedPath, patternDir) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|