Make exclude match on suffices by default

This commit is contained in:
Laurence Withers 2023-05-13 13:13:18 +01:00
parent 0276b1bfca
commit 5790d3ab5f
1 changed files with 6 additions and 1 deletions

View File

@ -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)
}