Filter links from pipeline

This commit is contained in:
Johannes Frohnmeyer 2022-11-03 14:50:53 +01:00
parent 4bc7ba11bf
commit 3ee3c34ffc
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 11 additions and 9 deletions

View File

@ -59,9 +59,7 @@ final class PipelineUnpacker implements BiConsumer<Pipeline, Consumer<Pipeline>>
for (String line : new StreamIterable<>(pipeline.data().lines())) {
Matcher matcher = INCLUDE.matcher(line);
if (!matcher.matches()) newData.append(line);
else {
newData.append(download(matcher.group(1)).data());
}
else newData.append(download(matcher.group(1)).data());
newData.append('\n');
}
processPipeline(new Pipeline(pipeline.name(), newData.toString()), pipelineConsumer, depth + 1);
@ -75,12 +73,16 @@ final class PipelineUnpacker implements BiConsumer<Pipeline, Consumer<Pipeline>>
processPipeline(download(url), pipelineConsumer, depth + 1);
}
if (pipeline.data().lines()
.anyMatch(INCLUDE.asPredicate().negate()
.and(LINK.asPredicate().negate())
.and(Predicate.not(String::isBlank)))) {
// More than just includes: generate override without include node
pipelineConsumer.accept(pipeline);
// Filter
StringBuilder newDate = new StringBuilder();
boolean foundContent = false;
for (String line : new StreamIterable<>(pipeline.data().lines())) {
if (LINK.matcher(line).matches()) continue;
if (!line.isBlank()) foundContent = true;
newDate.append(line).append('\n');
}
if (foundContent) {
pipelineConsumer.accept(new Pipeline(pipeline.name(), newDate.toString()));
}
}