/** * @param treeId the tree to retrieve * @return the {@link RevTree} referred to by the given {@link ObjectId} */ @Override public RevTree getTree(ObjectId treeId) { return command(RevObjectParse.class).setObjectId(treeId).call(RevTree.class).get(); }
/** * @param treeId the tree to retrieve * @return the {@link RevTree} referred to by the given {@link ObjectId} */ @Override public RevTree getTree(ObjectId treeId) { return command(RevObjectParse.class).setObjectId(treeId).call(RevTree.class).get(); }
/** * Retrieves an object with the specified id from the remote. * * @param objectId the object to get * @return the fetched object */ @Override protected Optional<RevObject> getObject(ObjectId objectId) { return remoteRepo.command(RevObjectParse.class).setObjectId(objectId).call(); }
/** * Retrieves an object with the specified id from the remote. * * @param objectId the object to get * @return the fetched object */ @Override protected Optional<RevObject> getObject(ObjectId objectId) { return remoteRepo.command(RevObjectParse.class).setObjectId(objectId).call(); }
/** * @return the tree referenced by the old ref, or the head of the index. */ private RevTree getOldTree() { final String oldVersion = Optional.fromNullable(refSpec).or(Ref.STAGE_HEAD); Optional<ObjectId> headTreeId = command(ResolveTreeish.class).setTreeish(oldVersion).call(); Preconditions.checkArgument(headTreeId.isPresent(), "Refspec " + oldVersion + " does not resolve to a tree"); final RevTree headTree; headTree = command(RevObjectParse.class).setObjectId(headTreeId.get()).call(RevTree.class) .get(); return headTree; }
/** * @return the tree referenced by the old ref, or the head of the index. */ private RevTree getOldTree() { final String oldVersion = Optional.fromNullable(refSpec).or(Ref.STAGE_HEAD); Optional<ObjectId> headTreeId = command(ResolveTreeish.class).setTreeish(oldVersion).call(); Preconditions.checkArgument(headTreeId.isPresent(), "Refspec " + oldVersion + " does not resolve to a tree"); final RevTree headTree; headTree = command(RevObjectParse.class).setObjectId(headTreeId.get()).call(RevTree.class) .get(); return headTree; }
@Override @Nullable public Feature apply(@Nullable NodeRef ref) { RevFeature revFeature = parseCommand.setObjectId(ref.getObjectId()) .call(RevFeature.class).get(); final String parentPath = ref.getParentPath(); FeatureBuilder featureBuilder = builders.get(parentPath); String fid = ref.name(); Feature feature = featureBuilder.build(fid, revFeature); return feature; }
@Override public RevTree get() { Optional<ObjectId> head = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call(); if (!head.isPresent() || head.get().isNull()) { return RevTree.EMPTY; } return command(RevObjectParse.class).setObjectId(head.get()).call(RevTree.class) .get(); } };
@Override public RevTree get() { Optional<ObjectId> head = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call(); if (!head.isPresent() || head.get().isNull()) { return RevTree.EMPTY; } return command(RevObjectParse.class).setObjectId(head.get()).call(RevTree.class) .get(); } };
private void printObject(String name, ObjectId id, Console console, GeoGIG geogig) throws IOException { console.println(name + "\t" + id.toString()); if (!id.isNull()) { Optional<RevObject> obj = geogig.command(RevObjectParse.class).setObjectId(id).call(); CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
/** * Helper function to parse the given commit id's feature information * * @param id - the id to parse out * @param geogig - an instance of geogig to run commands with * @return (Optional)NodeRef - the NodeRef that contains the metadata id and id needed to get * the feature and featuretype * * @throws CommandSpecException - if the treeid couldn't be resolved */ private Optional<NodeRef> parseID(ObjectId id, Context geogig) { RevTree tree = geogig.command(RevObjectParse.class).setObjectId(id).call(RevTree.class) .get(); return geogig.command(FindTreeChild.class).setParent(tree).setChildPath(path).call(); }
private void printObject(String name, ObjectId id, Console console, GeoGIG geogig) throws IOException { console.println(name + "\t" + id.toString()); if (!id.isNull()) { Optional<RevObject> obj = geogig.command(RevObjectParse.class).setObjectId(id).call(); CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
private void printObject(String name, ObjectId id, Console console, GeoGIG geogig) throws IOException { console.println(name + "\t" + id.toString()); if (!id.isNull()) { Optional<RevObject> obj = geogig.command(RevObjectParse.class).setObjectId(id).call(); CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
@Override public RevTree get() { if (treeId.isNull()) { return RevTree.EMPTY; } return geogig.command(RevObjectParse.class).setObjectId(treeId).call(RevTree.class) .get(); } };
@Override public RevTree get() { if (treeId.isNull()) { return RevTree.EMPTY; } return geogig.command(RevObjectParse.class).setObjectId(treeId).call(RevTree.class) .get(); } };
@Test public void testCommitWithDeletedTree() throws Exception { insertAndAdd(points1, points2); insertAndAdd(lines1, lines2); final RevCommit commit1 = geogig.command(CommitOp.class).call(); final RevTree tree1 = geogig.command(RevObjectParse.class).setObjectId(commit1.getTreeId()) .call(RevTree.class).get(); assertEquals(2, tree1.trees().size()); WorkingTree workingTree = geogig.getRepository().workingTree(); workingTree.delete(pointsName); geogig.command(AddOp.class).call(); final RevCommit commit2 = geogig.command(CommitOp.class).call(); RevTree tree2 = geogig.command(RevObjectParse.class).setObjectId(commit2.getTreeId()) .call(RevTree.class).get(); assertEquals(1, tree2.trees().size()); }
@Test public void testCheckoutPathFilter() throws Exception { ObjectId points1Id = insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); insert(points1_modified); CheckoutResult result = geogig.command(CheckoutOp.class).addPath("Points/Points.1").call(); Optional<RevTree> workTree = geogig.command(RevObjectParse.class) .setObjectId(result.getNewTree()).call(RevTree.class); Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get()) .setChildPath("Points/Points.1").call(); assertEquals(points1Id, nodeRef.get().getNode().getObjectId()); }
@Test public void testCheckoutPathFilter() throws Exception { ObjectId points1Id = insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); insert(points1_modified); CheckoutResult result = geogig.command(CheckoutOp.class).addPath("Points/Points.1").call(); Optional<RevTree> workTree = geogig.command(RevObjectParse.class) .setObjectId(result.getNewTree()).call(RevTree.class); Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get()) .setChildPath("Points/Points.1").call(); assertEquals(points1Id, nodeRef.get().getNode().getObjectId()); }
@Test public void testCommitEmptyTreeOnEmptyRepo() throws Exception { WorkingTree workingTree = geogig.getRepository().workingTree(); final String emptyTreeName = "emptyTree"; workingTree.createTypeTree(emptyTreeName, pointsType); geogig.command(AddOp.class).addPattern(emptyTreeName).call(); CommitOp commitCommand = geogig.command(CommitOp.class); RevCommit commit = commitCommand.call(); assertNotNull(commit); RevTree head = geogig.command(RevObjectParse.class).setObjectId(commit.getTreeId()) .call(RevTree.class).get(); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(emptyTreeName) .setParent(head).call(); assertTrue(ref.isPresent()); }
@Test public void testCommitEmptyTreeOnEmptyRepo() throws Exception { WorkingTree workingTree = geogig.getRepository().workingTree(); final String emptyTreeName = "emptyTree"; workingTree.createTypeTree(emptyTreeName, pointsType); geogig.command(AddOp.class).addPattern(emptyTreeName).call(); CommitOp commitCommand = geogig.command(CommitOp.class); RevCommit commit = commitCommand.call(); assertNotNull(commit); RevTree head = geogig.command(RevObjectParse.class).setObjectId(commit.getTreeId()) .call(RevTree.class).get(); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(emptyTreeName) .setParent(head).call(); assertTrue(ref.isPresent()); }