Skip to content

Commit c90c960

Browse files
authored
Revert ":bug: Adding tests for file searching and using relative path to base…"
This reverts commit 56d0a37.
1 parent 56d0a37 commit c90c960

File tree

12 files changed

+3
-394
lines changed

12 files changed

+3
-394
lines changed

provider/lib.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,30 +231,17 @@ func (f *FileSearcher) filterFilesByPathsOrPatterns(statFunc cachedOsStat, patte
231231
rPattern = "^" + pattern + "$"
232232
}
233233
// try matching as go regex pattern
234-
relPath, err := filepath.Rel(f.BasePath, file)
235-
if err != nil {
236-
// This should never happen, if paths are found outside the base path, then something did not occur
237-
// correctly.
238-
f.Log.Error(fmt.Errorf("unable to get relative path for file from base path"),
239-
"this should not happen, please file a bug", "basePath", f.BasePath, "filePath", file)
240-
continue
241-
}
242-
relPath = filepath.Join(string(os.PathSeparator), relPath)
243-
f.Log.V(9).Info("using regex to search", "pattern", pattern, "relPath", relPath)
244234
regex, regexErr := regexp.Compile(rPattern)
245-
if regexErr == nil && (regex.MatchString(relPath) || regex.MatchString(filepath.Base(file))) {
246-
f.Log.V(9).Info("regex match", "pattern", pattern, "relPath", relPath)
235+
if regexErr == nil && (regex.MatchString(file) || regex.MatchString(filepath.Base(file))) {
247236
patternMatched = true
248237
} else if strings.Contains(pattern, "*") || strings.Contains(pattern, "?") {
249238
// fallback to filepath.Match for simple patterns
250-
m, err := filepath.Match(pattern, relPath)
239+
m, err := filepath.Match(pattern, file)
251240
if err == nil {
252-
f.Log.V(9).Info("filepath match", "pattern", pattern, "relPath", relPath)
253241
patternMatched = patternMatched || m
254242
}
255-
m, err = filepath.Match(pattern, filepath.Base(relPath))
243+
m, err = filepath.Match(pattern, filepath.Base(file))
256244
if err == nil {
257-
f.Log.V(9).Info("file name match", "pattern", pattern, "relPath", relPath)
258245
patternMatched = patternMatched || m
259246
}
260247
}

0 commit comments

Comments
 (0)