Skip to content

Commit 8f6e3bd

Browse files
crackcommlidel
authored andcommitted
fix: recursive directory filtering in ShouldExclude
Ensure ignore rule `bar/` matches directories by appending `/`. Addresses issue where `bar/` didn't catch directories. After this change, both `bar` and `bar/` rules filter out the `bar` directory and its contents.
1 parent b101ba0 commit 8f6e3bd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

files/filter.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package files
22

33
import (
4+
"fmt"
45
"os"
56

67
ignore "github.com/crackcomm/go-gitignore"
@@ -45,5 +46,8 @@ func (filter *Filter) ShouldExclude(fileInfo os.FileInfo) (result bool) {
4546
if !filter.IncludeHidden && isHidden(fileInfo) {
4647
return true
4748
}
49+
if fileInfo.IsDir() {
50+
path = fmt.Sprintf("%s/", path)
51+
}
4852
return filter.Rules.MatchesPath(path)
4953
}

0 commit comments

Comments
 (0)