raboof commented on code in PR #433: URL: https://github.com/apache/creadur-rat/pull/433#discussion_r2099876523
########## 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: Ah yes, sorry for not calling that out - I wanted to make sure this is covered in a testcase before making the code change :) -- 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