Fix FindFilterFiles
There are two bugs in the handling of exclusion patterns: - The paths being checked against patterns are relative, so leading / need to be stripped - filepath.Match only does a string comparison, and the paths we traverse don't include trailing / Signed-off-by: Tobias Ribizel <mail@ribizel.de>
This commit is contained in:
@@ -260,6 +260,10 @@ func FindFilterFiles(
|
||||
ignorePattern []string,
|
||||
ignore_xdev bool) (ofiles []string, err error) {
|
||||
wwlog.Debug("Finding files: %s include: %s ignore: %s", path, includePattern, ignorePattern)
|
||||
// preprocess patterns to remove leading (and trailing) /, as we are handling relative paths
|
||||
for i, pattern := range ignorePattern {
|
||||
ignorePattern[i] = strings.Trim(pattern, "/")
|
||||
}
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return ofiles, err
|
||||
@@ -319,6 +323,7 @@ func FindFilterFiles(
|
||||
}
|
||||
for _, ignored_pat := range ignorePattern {
|
||||
if ignored, _ := filepath.Match(ignored_pat, location); ignored {
|
||||
wwlog.Debug("Ignored %s due to pattern %s", location, ignored_pat)
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user