fix: support exclude patterns on Windows (#1228)

This commit is contained in:
Keith Zantow
2022-09-26 10:59:19 -04:00
committed by GitHub
parent 30e8c4ab8e
commit 16c62a1378
3 changed files with 128 additions and 0 deletions
+5
View File
@@ -392,6 +392,9 @@ func getDirectoryExclusionFunctions(root string, exclusions []string) ([]pathFil
return nil, err
}
// this handles Windows file paths by converting them to C:/something/else format
root = filepath.ToSlash(root)
if !strings.HasSuffix(root, "/") {
root += "/"
}
@@ -414,6 +417,8 @@ func getDirectoryExclusionFunctions(root string, exclusions []string) ([]pathFil
return []pathFilterFn{
func(path string, _ os.FileInfo) bool {
for _, exclusion := range exclusions {
// this is required to handle Windows filepaths
path = filepath.ToSlash(path)
matches, err := doublestar.Match(exclusion, path)
if err != nil {
return false