Improve file exclusion

This commit is contained in:
RatzzFatzz
2025-12-16 00:50:57 +01:00
parent 2ecea906b1
commit cf04e14de2
3 changed files with 30 additions and 15 deletions

View File

@@ -70,9 +70,18 @@ public class FileFilter {
private boolean isExcluded(File pathName, Set<String> excludedDirs) {
if (excludedDirs.contains(pathName.getPath())) return true;
// TODO improve partial matches and wildcard?
String[] pathSplit = pathName.getPath().split("/");
for (String excludedDir : excludedDirs) {
if (pathName.getPath().startsWith(excludedDir)) return true;
String[] excludeSplit = excludedDir.split("/");
if (excludeSplit.length > pathSplit.length) continue;
boolean matchingPaths = true;
for (int i = 0; i < excludeSplit.length; i++) {
if (!excludeSplit[i].equals(pathSplit[i])) {
matchingPaths = false;
break;
}
}
if (matchingPaths) return true;
}
return false;

View File

@@ -59,7 +59,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
@Option(names = {"-i", "--include-pattern"}, defaultValue = ".*", description = "include files matching pattern (default: \".*\")")
private Pattern includePattern;
@Option(names = {"-e", "--excluded"}, arity = "1..*",
description = "Directories and files to be excluded (no wildcard)")
description = "relative directories and files to be excluded (no wildcard)")
private Set<String> excluded = new HashSet<>();