Skip to content

Commit

Permalink
fix: Fixing non ignored .fibr folder when no ignore
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Mar 8, 2023
1 parent 6efb29f commit 364b3ee
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,28 @@ func Flags(fs *flag.FlagSet, prefix string) Config {
}

func Get(config Config, storage absto.Storage) (absto.Storage, error) {
ignore := *config.ignore
if len(ignore) == 0 {
return storage, nil
}
var pattern *regexp.Regexp

pattern, err := regexp.Compile(ignore)
if err != nil {
return storage, fmt.Errorf("regexp compile: %w", err)
}
if ignore := *config.ignore; len(ignore) != 0 {
var err error

pattern, err = regexp.Compile(ignore)
if err != nil {
return storage, fmt.Errorf("regexp compile: %w", err)
}

logger.Info("Ignoring files with pattern `%s`", ignore)
logger.Info("Ignoring files with pattern `%s`", ignore)
}

filteredStorage := storage.WithIgnoreFn(func(item absto.Item) bool {
return storage.WithIgnoreFn(func(item absto.Item) bool {
if strings.HasPrefix(item.Pathname, provider.MetadataDirectoryName) {
return true
}

if pattern.MatchString(item.Name) {
if pattern != nil && pattern.MatchString(item.Name) {
return true
}

return false
})

return filteredStorage, nil
}), nil
}

0 comments on commit 364b3ee

Please sign in to comment.