Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config includes when any pattern has no match #95

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion filesearch/filesearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions filesearch/filesearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}},
Expand Down