List of usage examples for org.eclipse.jgit.treewalk TreeWalk TreeWalk
public TreeWalk(@Nullable Repository repo, ObjectReader or)
From source file:com.creactiviti.piper.core.git.JGitTemplate.java
License:Apache License
private List<IdentifiableResource> getHeadFiles(Repository aRepository, String... aSearchPaths) { List<String> searchPaths = Arrays.asList(aSearchPaths); List<IdentifiableResource> resources = new ArrayList<>(); try (ObjectReader reader = aRepository.newObjectReader(); RevWalk walk = new RevWalk(reader); TreeWalk treeWalk = new TreeWalk(aRepository, reader);) { final ObjectId id = aRepository.resolve(Constants.HEAD); RevCommit commit = walk.parseCommit(id); RevTree tree = commit.getTree(); treeWalk.addTree(tree);/* w ww . j ava2 s . c om*/ treeWalk.setRecursive(true); while (treeWalk.next()) { String path = treeWalk.getPathString(); if (searchPaths.stream().anyMatch((sp) -> path.startsWith(sp))) { ObjectId objectId = treeWalk.getObjectId(0); logger.debug("Loading {} [{}]", path, objectId.name()); resources.add(readBlob(aRepository, path.substring(0, path.indexOf('.')), objectId.name())); } } return resources; } catch (Exception e) { throw Throwables.propagate(e); } }