Make doublestar a little cleaner
This commit is contained in:
14
main.go
14
main.go
@@ -226,10 +226,20 @@ func expandFilePatterns(patterns []string) ([]string, error) {
|
||||
var files []string
|
||||
filesMap := make(map[string]bool)
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get current working directory: %w", err)
|
||||
}
|
||||
for _, pattern := range patterns {
|
||||
matches, _ := doublestar.Glob(os.DirFS("."), pattern)
|
||||
matches, _ := doublestar.Glob(os.DirFS(cwd), pattern)
|
||||
log.Printf("Found %d matches for pattern %s", len(matches), pattern)
|
||||
for _, m := range matches {
|
||||
if info, err := os.Stat(m); err == nil && !info.IsDir() && !filesMap[m] {
|
||||
info, err := os.Stat(m)
|
||||
if err != nil {
|
||||
logger.Printf("Error getting file info for %s: %v", m, err)
|
||||
continue
|
||||
}
|
||||
if !info.IsDir() && !filesMap[m] {
|
||||
filesMap[m], files = true, append(files, m)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user