Skip to content

Commit

Permalink
fix: recursive directory filtering in ShouldExclude
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crackcomm committed Nov 23, 2023
1 parent d06f7ff commit fe0a823
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions files/filter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package files

import (
"fmt"
"os"

ignore "github.com/crackcomm/go-gitignore"
Expand Down Expand Up @@ -45,5 +46,8 @@ func (filter *Filter) ShouldExclude(fileInfo os.FileInfo) (result bool) {
if !filter.IncludeHidden && isHidden(fileInfo) {
return true
}
if fileInfo.IsDir() {
path = fmt.Sprintf("%s/", path)
}
return filter.Rules.MatchesPath(path)
}

0 comments on commit fe0a823

Please sign in to comment.