use of org.eclipse.jgit.revwalk.DepthWalk.RevWalk in project jwt by emweb.
the class Git method treeGetObject.
public Object treeGetObject(ObjectId treeObject, int childIndex) {
try {
RevWalk walk = new RevWalk(repository, 0);
RevTree tree = walk.parseTree(treeObject.id);
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(tree);
treeWalk.setRecursive(false);
for (int i = 0; i <= childIndex; ++i) if (!treeWalk.next())
throw new RuntimeException("No object " + childIndex + " in tree " + treeObject.id.toString());
Object object = new Object();
object.id = new ObjectId(treeWalk.getObjectId(0));
object.type = treeWalk.getFileMode(0) == FileMode.TREE ? ObjectType.Tree : ObjectType.Blob;
object.name = treeWalk.getNameString();
return object;
} catch (MissingObjectException e) {
throw new RuntimeException(e);
} catch (IncorrectObjectTypeException e) {
throw new RuntimeException(e);
} catch (CorruptObjectException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.jgit.revwalk.DepthWalk.RevWalk in project jwt by emweb.
the class Git method treeSize.
public int treeSize(ObjectId treeId) {
if (treeId.id == null)
return 0;
try {
RevWalk walk = new RevWalk(repository, 0);
RevTree tree = walk.parseTree(treeId.id);
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(tree);
treeWalk.setRecursive(false);
int count = 0;
while (treeWalk.next()) ++count;
return count;
} catch (MissingObjectException e) {
throw new RuntimeException(e);
} catch (IncorrectObjectTypeException e) {
throw new RuntimeException(e);
} catch (CorruptObjectException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations