use of org.eclipse.jgit.errors.MissingObjectException in project orgzly-android by orgzly.
the class GitRepo method getBooks.
public List<VersionedRook> getBooks() throws IOException {
synchronizer.setBranchAndGetLatest();
List<VersionedRook> result = new ArrayList<>();
if (synchronizer.currentHead() == null) {
return result;
}
TreeWalk walk = new TreeWalk(git.getRepository());
walk.reset();
walk.setRecursive(true);
walk.addTree(synchronizer.currentHead().getTree());
final IgnoreNode ignores = getIgnores();
walk.setFilter(new TreeFilter() {
@Override
public boolean include(TreeWalk walker) throws MissingObjectException, IncorrectObjectTypeException, IOException {
final FileMode mode = walker.getFileMode(0);
final String filePath = walker.getPathString();
final boolean isDirectory = mode == FileMode.TREE;
return !(ignores.isIgnored(filePath, isDirectory) == IgnoreNode.MatchResult.IGNORED);
}
@Override
public boolean shouldBeRecursive() {
return true;
}
@Override
public TreeFilter clone() {
return this;
}
});
while (walk.next()) {
final FileMode mode = walk.getFileMode(0);
final boolean isDirectory = mode == FileMode.TREE;
final String filePath = walk.getPathString();
if (isDirectory)
continue;
if (BookName.isSupportedFormatFileName(filePath))
result.add(currentVersionedRook(Uri.withAppendedPath(Uri.EMPTY, walk.getPathString())));
}
return result;
}
Aggregations