Claudenw commented on code in PR #433: URL: https://github.com/apache/creadur-rat/pull/433#discussion_r2099478951
########## apache-rat-core/src/main/java/org/apache/rat/config/exclusion/fileProcessors/GitIgnoreBuilder.java: ########## @@ -53,6 +58,43 @@ public GitIgnoreBuilder() { super(IGNORE_FILE, COMMENT_PREFIX, true); } + private MatcherSet processGlobalIgnore(final Consumer<MatcherSet> matcherSetConsumer, final DocumentName root, final DocumentName globalGitIgnore) { + final MatcherSet.Builder matcherSetBuilder = new MatcherSet.Builder(); + final List<String> iterable = new ArrayList<>(); + ExclusionUtils.asIterator(globalGitIgnore.asFile(), commentFilter) + .map(entry -> modifyEntry(matcherSetConsumer, globalGitIgnore, entry).orElse(null)) + .filter(Objects::nonNull) + .map(entry -> ExclusionUtils.qualifyPattern(root, entry)) + .forEachRemaining(iterable::add); + + Set<String> included = new HashSet<>(); + Set<String> excluded = new HashSet<>(); + MatcherSet.Builder.segregateList(excluded, included, iterable); + DocumentName displayName = DocumentName.builder(root).setName("global gitignore").build(); + matcherSetBuilder.addExcluded(displayName, excluded); + matcherSetBuilder.addIncluded(displayName, included); + return matcherSetBuilder.build(); + } + + @Override + protected MatcherSet process(final Consumer<MatcherSet> matcherSetConsumer, final DocumentName root, final DocumentName documentName) { + if (root.equals(documentName.getBaseDocumentName())) { + Optional<File> globalGitIgnore = globalGitIgnore(); + List<MatcherSet> matcherSets = new ArrayList<MatcherSet>(); + matcherSets.add(super.process(matcherSetConsumer, root, documentName)); + if (globalGitIgnore.isPresent()) { + LevelBuilder levelBuilder = getLevelBuilder(-1); Review Comment: I still think that `-1` needs to be `Integer.MAX_VALUE` You want it last in the list of levels so that when the list is iterated in the reverse order your ignore comes first. remember that if there are levels 0, 1, 2, 3 the rules are applied in reverse order (3, 2, 1, 0). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@creadur.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org