INNER CODE UNIT · Java
getChangedModules
quarkusio/quarkus-super-heroes · .github/calculateModules.java:36
private static Set<String> getChangedModules(String timeframe) throws IOException, InterruptedException {
// Use git log to get a list of all the files that changed in the timeframe
var process = ProcessBuilder.startPipeline(
List.of(
new ProcessBuilder("git", "log", "--pretty=format:", "--since=\"%s ago\"".formatted(timeframe), "--name-only"),
new ProcessBuilder("sort")
)
).getLast();
process.waitFor();
try (var reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
return reader.lines()
.filter(calculateModules::shouldIncludeFile)
.map(fullFileName -> fullFileName.trim().split("/")[0]) // Grab just the first path, which will be the directory name
.filter(MODULES::contains) // Only keep it if it is one of the module names
.collect(Collectors.toCollection(LinkedHashSet::new));
}