use of com.googlecode.prolog_cafe.exceptions.PrologException in project gerrit by GerritCodeReview.
the class PRED_files_1 method getAllSubmodulePaths.
/**
* Returns the paths for all {@code GITLINK} files.
*/
private static Set<String> getAllSubmodulePaths(Repository repository, RevCommit commit, Collection<FileDiffOutput> modifiedFiles) throws PrologException, IOException {
Set<String> submodules = new HashSet<>();
try (TreeWalk treeWalk = new TreeWalk(repository)) {
treeWalk.addTree(commit.getTree());
Set<String> allPaths = modifiedFiles.stream().map(f -> FilePathAdapter.getNewPath(f.oldPath(), f.newPath(), f.changeType())).filter(f -> !Patch.isMagic(f)).collect(Collectors.toSet());
treeWalk.setFilter(PathFilterGroup.createFromStrings(allPaths));
while (treeWalk.next()) {
if (treeWalk.getFileMode() == FileMode.GITLINK) {
submodules.add(treeWalk.getPathString());
}
}
return submodules;
}
}
Aggregations