Refactor GitTreeReader

This commit is contained in:
Paul Campbell 2018-06-15 18:20:05 +01:00
parent dc932d8b1d
commit 53e1fd394b

View file

@ -55,7 +55,8 @@ class GitTreeReader {
*/ */
Stream<NamedRevBlob> stream(final Ref branchRef) throws IOException { Stream<NamedRevBlob> stream(final Ref branchRef) throws IOException {
final TreeWalk treeWalk = new TreeWalk(repository); final TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(new RevWalk(repository).parseCommit(branchRef.getObjectId()).getTree()); final RevWalk revWalk = new RevWalk(repository);
treeWalk.addTree(revWalk.parseCommit(branchRef.getObjectId()).getTree());
treeWalk.setRecursive(false); treeWalk.setRecursive(false);
Optional.ofNullable(treeFilter) Optional.ofNullable(treeFilter)
.ifPresent(treeWalk::setFilter); .ifPresent(treeWalk::setFilter);
@ -63,7 +64,7 @@ class GitTreeReader {
while (treeWalk.next()) { while (treeWalk.next()) {
builder.add(new NamedRevBlob( builder.add(new NamedRevBlob(
treeWalk.getNameString(), treeWalk.getNameString(),
new RevWalk(repository).lookupBlob(treeWalk.getObjectId(0)), revWalk.lookupBlob(treeWalk.getObjectId(0)),
repository)); repository));
} }
return builder.build(); return builder.build();