From 86eebc994900579d2954e7a8ccd3a8f272c62804 Mon Sep 17 00:00:00 2001 From: Juergen Kellerer Date: Fri, 25 Feb 2022 22:24:26 +0100 Subject: [PATCH] Fix config includes when any pattern has no match --- filesearch/filesearch.go | 5 ++++- filesearch/filesearch_test.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/filesearch/filesearch.go b/filesearch/filesearch.go index 6ed9f72d..14992485 100644 --- a/filesearch/filesearch.go +++ b/filesearch/filesearch.go @@ -141,6 +141,7 @@ func FindConfigurationIncludes(configFile string, includes []string) ([]string, addFile := func(file string) { file = filepath.FromSlash(filepath.Clean(file)) if file != configFile { + clog.Tracef("include: %s", file) files = append(files, file) } } @@ -159,8 +160,10 @@ func FindConfigurationIncludes(configFile string, includes []string) ([]string, for _, match := range matches { addFile(match) } + } else if err == nil { + clog.Debugf("no match: %s", include) } else { - return nil, err + return nil, fmt.Errorf("%w: %q", err, include) } } } diff --git a/filesearch/filesearch_test.go b/filesearch/filesearch_test.go index c790d58e..7eb6eea6 100644 --- a/filesearch/filesearch_test.go +++ b/filesearch/filesearch_test.go @@ -312,6 +312,7 @@ func TestFindConfigurationIncludes(t *testing.T) { {[]string{"*inc*." + testID + ".*"}, files[1:]}, {[]string{"inc1." + testID + ".conf"}, files[1:2]}, {[]string{"inc3." + testID + ".conf", "inc1." + testID + ".conf"}, []string{files[3], files[1]}}, + {[]string{"inc3." + testID + ".conf", "no-match"}, []string{files[3]}}, // Does not include self {[]string{"base." + testID + ".conf"}, []string{}}, {files[0:1], []string{}},