From 5790d3ab5fffb26082877dfd5ebf17d34af86e6c Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Sat, 13 May 2023 13:13:18 +0100 Subject: [PATCH] Make exclude match on suffices by default --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 9483c93..254c88e 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "regexp" + "strings" "github.com/bmatcuk/doublestar/v4" "github.com/spf13/cobra" @@ -94,7 +95,11 @@ func run(c *cobra.Command, args []string) error { searchPath = append(searchPath, ".") } - for _, x := range excludeList { + for i, x := range excludeList { + if !strings.HasPrefix(x, "**/") && !strings.HasPrefix(x, "./") { + x = "**/" + x + excludeList[i] = x + } if !doublestar.ValidatePattern(x) { return fmt.Errorf("invalid exclude pattern %q", x) }