/** * Pass through to the original {@link StagingArea}. */ @Override public AutoCloseableIterator<DiffEntry> getStaged(@Nullable List<String> pathFilters) { return index.getStaged(pathFilters); }
/** * Pass through to the original {@link StagingArea}. */ @Override public AutoCloseableIterator<DiffEntry> getStaged(@Nullable List<String> pathFilters) { return index.getStaged(pathFilters); }
@Test public void testAddSingleDeletion() throws Exception { insert(points1); insert(points2); geogig.command(AddOp.class).call(); List<DiffEntry> staged = toList(repo.index().getStaged(Lists.newArrayList(pointsName))); assertEquals(3, staged.size()); delete(points1); geogig.command(AddOp.class).call(); staged = toList(repo.index().getStaged(Lists.newArrayList(pointsName))); assertEquals(2, staged.size()); }
@Test public void testAddSingleDeletion() throws Exception { insert(points1); insert(points2); geogig.command(AddOp.class).call(); List<DiffEntry> staged = toList(repo.index().getStaged(Lists.newArrayList(pointsName))); assertEquals(3, staged.size()); delete(points1); geogig.command(AddOp.class).call(); staged = toList(repo.index().getStaged(Lists.newArrayList(pointsName))); assertEquals(2, staged.size()); }
try (AutoCloseableIterator<DiffEntry> staged = index.getStaged(null)) { if (null == pathFilter && !staged.hasNext() && !updateOnly && index.countConflicted(null) == 0) {
try (AutoCloseableIterator<DiffEntry> staged = index.getStaged(null)) { if (null == pathFilter && !staged.hasNext() && !updateOnly && index.countConflicted(null) == 0) {
@Test public void testAddNewPathUsingPathFilter() throws Exception { insert(points1); insert(points2); geogig.command(AddOp.class).addPattern("Points/Points.1").call(); List<DiffEntry> unstaged = toList(repo.index().getStaged(null)); assertEquals(unstaged.toString(), 2, unstaged.size()); assertEquals(ChangeType.ADDED, unstaged.get(0).changeType()); assertEquals(RevObject.TYPE.TREE, unstaged.get(0).getNewObject().getType()); assertEquals("Points", unstaged.get(0).newName()); RevFeatureType ft = RevFeatureTypeBuilder.build(pointsType); ObjectId expectedTreeMdId = ft.getId(); assertEquals(expectedTreeMdId, unstaged.get(0).getNewObject().getMetadataId()); assertEquals(ChangeType.ADDED, unstaged.get(1).changeType()); assertEquals(RevObject.TYPE.FEATURE, unstaged.get(1).getNewObject().getType()); assertEquals("Points.1", unstaged.get(1).newName()); assertFalse("feature node's metadata id should not be set, as it uses the parent tree one", unstaged.get(1).getNewObject().getNode().getMetadataId().isPresent()); }
@Test public void testAddNewPathUsingPathFilter() throws Exception { insert(points1); insert(points2); geogig.command(AddOp.class).addPattern("Points/Points.1").call(); List<DiffEntry> unstaged = toList(repo.index().getStaged(null)); assertEquals(unstaged.toString(), 2, unstaged.size()); assertEquals(ChangeType.ADDED, unstaged.get(0).changeType()); assertEquals(RevObject.TYPE.TREE, unstaged.get(0).getNewObject().getType()); assertEquals("Points", unstaged.get(0).newName()); RevFeatureType ft = RevFeatureType.builder().type(pointsType).build(); ObjectId expectedTreeMdId = ft.getId(); assertEquals(expectedTreeMdId, unstaged.get(0).getNewObject().getMetadataId()); assertEquals(ChangeType.ADDED, unstaged.get(1).changeType()); assertEquals(RevObject.TYPE.FEATURE, unstaged.get(1).getNewObject().getType()); assertEquals("Points.1", unstaged.get(1).newName()); assertFalse("feature node's metadata id should not be set, as it uses the parent tree one", unstaged.get(1).getNewObject().getNode().getMetadataId().isPresent()); }
@Test public void testAddUpdateWithPathFilter() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); insert(points1_modified); insert(lines1); // stage only Lines changed geogig.command(AddOp.class).setUpdateOnly(true).addPattern(pointsName).call(); List<DiffEntry> staged = toList(repo.index().getStaged(null)); assertEquals(2, staged.size()); assertEquals(pointsName, staged.get(0).newName()); assertEquals(idP1, staged.get(1).newName()); List<DiffEntry> unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); geogig.command(AddOp.class).setUpdateOnly(true).addPattern("Points").call(); unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); }
@Test public void testAddUpdateWithPathFilter() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); insert(points1_modified); insert(lines1); // stage only Lines changed geogig.command(AddOp.class).setUpdateOnly(true).addPattern(pointsName).call(); List<DiffEntry> staged = toList(repo.index().getStaged(null)); assertEquals(2, staged.size()); assertEquals(pointsName, staged.get(0).newName()); assertEquals(idP1, staged.get(1).newName()); List<DiffEntry> unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); geogig.command(AddOp.class).setUpdateOnly(true).addPattern("Points").call(); unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); }
List<DiffEntry> staged = toList(index.getStaged(null)); assertEquals(staged.toString(), 1, staged.size());
@Test public void testAddTreeDeletion() throws Exception { insert(points1); insert(points2); geogig.command(AddOp.class).call(); repo.workingTree().delete(pointsName); geogig.command(AddOp.class).call(); List<DiffEntry> staged = toList(repo.index().getStaged(Lists.newArrayList(pointsName))); assertEquals(0, staged.size()); assertEquals(0, repo.index().countStaged(null).featureCount()); assertEquals(0, repo.index().countStaged(null).treeCount()); }
@Test public void testAddTreeDeletion() throws Exception { insert(points1); insert(points2); geogig.command(AddOp.class).call(); repo.workingTree().delete(pointsName); geogig.command(AddOp.class).call(); List<DiffEntry> staged = toList(repo.index().getStaged(Lists.newArrayList(pointsName))); assertEquals(0, staged.size()); assertEquals(0, repo.index().countStaged(null).featureCount()); assertEquals(0, repo.index().countStaged(null).treeCount()); }
@Test public void testTreeRemoval() throws Exception { populate(false, points1, points2, points3, lines1, lines2); DiffObjectCount result = geogig.command(RemoveOp.class).addPathToRemove(pointsName) .setRecursive(true).call(); assertEquals(3, result.getFeaturesRemoved()); assertEquals(1, result.getTreesRemoved()); Optional<ObjectId> id = geogig.command(RevParse.class) .setRefSpec(Ref.WORK_HEAD + ":" + pointsName).call(); assertFalse(id.isPresent()); id = geogig.command(RevParse.class).setRefSpec(Ref.STAGE_HEAD + ":" + pointsName).call(); List<DiffEntry> list = toList(repo.index().getStaged(null)); assertEquals(4, list.size()); assertFalse(id.isPresent()); id = geogig.command(RevParse.class).setRefSpec(Ref.STAGE_HEAD + ":" + linesName).call(); assertTrue(id.isPresent()); }
List<DiffEntry> staged = toList(index.getStaged(null)); assertEquals(staged.toString(), 1, staged.size());
@Test public void testTreeRemoval() throws Exception { populate(false, points1, points2, points3, lines1, lines2); DiffObjectCount result = geogig.command(RemoveOp.class).addPathToRemove(pointsName) .setRecursive(true).call(); assertEquals(3, result.getFeaturesRemoved()); assertEquals(1, result.getTreesRemoved()); Optional<ObjectId> id = geogig.command(RevParse.class) .setRefSpec(Ref.WORK_HEAD + ":" + pointsName).call(); assertFalse(id.isPresent()); id = geogig.command(RevParse.class).setRefSpec(Ref.STAGE_HEAD + ":" + pointsName).call(); List<DiffEntry> list = toList(repo.index().getStaged(null)); assertFalse(id.isPresent()); id = geogig.command(RevParse.class).setRefSpec(Ref.STAGE_HEAD + ":" + linesName).call(); assertTrue(id.isPresent()); }
@Test public void testAddModifiedFeatureType() throws Exception { insertAndAdd(points2, points1B); geogig.command(CommitOp.class).call(); geogig.getRepository().workingTree().updateTypeTree(pointsName, modifiedPointsType); geogig.command(AddOp.class).call(); List<DiffEntry> list = toList(geogig.getRepository().index().getStaged(null)); assertFalse(list.isEmpty()); String path = NodeRef.appendChild(pointsName, idP1); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(path) .setParent(geogig.getRepository().index().getTree()).call(); assertTrue(ref.isPresent()); assertFalse(ref.get().getNode().getMetadataId().isPresent()); path = NodeRef.appendChild(pointsName, idP2); ref = geogig.command(FindTreeChild.class).setChildPath(path) .setParent(geogig.getRepository().index().getTree()).call(); assertTrue(ref.isPresent()); assertTrue(ref.get().getNode().getMetadataId().isPresent()); } }
@Test public void testAddModifiedFeatureType() throws Exception { insertAndAdd(points2, points1B); geogig.command(CommitOp.class).call(); geogig.getRepository().workingTree().updateTypeTree(pointsName, modifiedPointsType); geogig.command(AddOp.class).call(); List<DiffEntry> list = toList(geogig.getRepository().index().getStaged(null)); assertFalse(list.isEmpty()); String path = NodeRef.appendChild(pointsName, idP1); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(path) .setParent(geogig.getRepository().index().getTree()).call(); assertTrue(ref.isPresent()); assertFalse(ref.get().getNode().getMetadataId().isPresent()); path = NodeRef.appendChild(pointsName, idP2); ref = geogig.command(FindTreeChild.class).setChildPath(path) .setParent(geogig.getRepository().index().getTree()).call(); assertTrue(ref.isPresent()); assertTrue(ref.get().getNode().getMetadataId().isPresent()); } }