Add more logging to the file filtering

This commit is contained in:
Tamas Vajk
2023-12-13 14:14:07 +01:00
parent 694be29311
commit c870b0d4e9
2 changed files with 87 additions and 22 deletions

View File

@@ -59,7 +59,9 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
continue;
}
pathFilters.Add(new PathFilter(new Regex(new FilePattern(filterText).RegexPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline), include));
var regex = new FilePattern(filterText).RegexPattern;
progressMonitor.Log(Severity.Info, $"Filtering {(include ? "in" : "out")} files matching '{regex}'. Original glob filter: '{filter}'");
pathFilters.Add(new PathFilter(new Regex(regex, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline), include));
}
var fileIndex = files.ToDictionary(f => f, f => new FileInclusion(FileUtils.ConvertToUnix(f.FullName.ToLowerInvariant()).Replace(rootFolder, string.Empty).TrimStart('/'), pathFilters.All(f => !f.Include)));
@@ -75,7 +77,20 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
}
}
return fileIndex.Where(f => f.Value.Include).Select(f => f.Key);
var included = new List<FileInfo>();
foreach (var file in fileIndex)
{
if (file.Value.Include)
{
included.Add(file.Key);
}
else
{
progressMonitor.Log(Severity.Info, $"Excluding '{file.Key.FullName}'");
}
}
return included;
}
}
}