mirror of
https://github.com/LukeHagar/slinky.git
synced 2025-12-06 04:21:20 +00:00
Refactor ignore path handling in fsurls.go to improve whitespace trimming and add recursive matching for directory-like patterns. Enhance the logic to compile ignore lines more effectively, ensuring better support for various ignore scenarios.
This commit is contained in:
@@ -649,7 +649,28 @@ func loadSlinkyIgnore(root string) (*ignore.GitIgnore, []string) {
|
||||
}
|
||||
var ign *ignore.GitIgnore
|
||||
if len(cfg.IgnorePaths) > 0 {
|
||||
ign = ignore.CompileIgnoreLines(cfg.IgnorePaths...)
|
||||
var lines []string
|
||||
for _, p := range cfg.IgnorePaths {
|
||||
p = strings.TrimSpace(p)
|
||||
if p == "" {
|
||||
continue
|
||||
}
|
||||
lines = append(lines, p)
|
||||
// Add a recursive variant to match anywhere
|
||||
if !strings.HasPrefix(p, "**/") {
|
||||
lines = append(lines, "**/"+p)
|
||||
}
|
||||
// If likely a directory name, add a catch-all under it
|
||||
base := strings.TrimSuffix(p, "/")
|
||||
if base != "" && !strings.ContainsAny(base, "*?[]") {
|
||||
// Heuristic: directory-like if it has no '.' in the last segment or explicitly ends with '/'
|
||||
last := filepath.Base(base)
|
||||
if strings.HasSuffix(p, "/") || !strings.Contains(last, ".") {
|
||||
lines = append(lines, "**/"+base+"/**")
|
||||
}
|
||||
}
|
||||
}
|
||||
ign = ignore.CompileIgnoreLines(lines...)
|
||||
}
|
||||
var urlPatterns []string
|
||||
for _, p := range cfg.IgnoreURLs {
|
||||
|
||||
Reference in New Issue
Block a user