@Test public void testPathFilterByTypeName() throws Exception { List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3); LinkedList<RevCommit> commits = Lists.newLinkedList(); LinkedList<RevCommit> typeName1Commits = Lists.newLinkedList(); for (Feature f : features) { insertAndAdd(f); final RevCommit commit = geogig.command(CommitOp.class) .setMessage(f.getIdentifier().toString()).call(); commits.addFirst(commit); if (pointsName.equals(f.getType().getName().getLocalPart())) { typeName1Commits.addFirst(commit); } } // path to filter commits on type1 String path = pointsName; List<RevCommit> logCommits = toList(logOp.addPath(path).call()); assertEquals(typeName1Commits.size(), logCommits.size()); assertEquals(typeName1Commits, logCommits); }
@Test public void testPathFilterByTypeName() throws Exception { List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3); LinkedList<RevCommit> commits = Lists.newLinkedList(); LinkedList<RevCommit> typeName1Commits = Lists.newLinkedList(); for (Feature f : features) { insertAndAdd(f); final RevCommit commit = geogig.command(CommitOp.class) .setMessage(f.getIdentifier().toString()).call(); commits.addFirst(commit); if (pointsName.equals(f.getType().getName().getLocalPart())) { typeName1Commits.addFirst(commit); } } // path to filter commits on type1 String path = pointsName; List<RevCommit> logCommits = toList(logOp.addPath(path).call()); assertEquals(typeName1Commits.size(), logCommits.size()); assertEquals(typeName1Commits, logCommits); }
private static Set<IndexTreeMapping> getIndexMappings(IndexInfo indexInfo, Repository repo, Optional<String> ref) { if (!ref.isPresent()) { return Sets.newHashSet(repo.indexDatabase().resolveIndexedTrees(indexInfo)); } Set<IndexTreeMapping> mappings = new HashSet<>(); List<Ref> branches = getBranches(repo, ref); for (Ref branch : branches) { List<RevCommit> commits = Lists.newArrayList(repo.command(LogOp.class) .addPath(indexInfo.getTreeName()).setUntil(branch.getObjectId()).call()); for (RevCommit c : commits) { String treeRef = String.format("%s:%s", c.getId(), indexInfo.getTreeName()); ObjectId canonicalTreeId = repo.command(RevParse.class).setRefSpec(treeRef).call() .get(); Optional<ObjectId> indexedTree = repo.indexDatabase().resolveIndexedTree(indexInfo, canonicalTreeId); String msg = String.format("Expected index at %s:%s", branch.getName(), indexInfo.getTreeName()); assertTrue(msg, indexedTree.isPresent()); mappings.add(new IndexTreeMapping(canonicalTreeId, indexedTree.get())); } } return mappings; }
Iterator<RevCommit> log = command(LogOp.class).addPath(path).setUntil(commit).call(); RevCommit commit = log.next(); RevObjectParse revObjectParse = command(RevObjectParse.class);
Iterator<RevCommit> log = command(LogOp.class).addPath(path).setUntil(commit).call(); RevCommit commit = log.next(); RevObjectParse revObjectParse = command(RevObjectParse.class);
@Test public void testPathFilterSingleFeature() throws Exception { List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3); List<RevCommit> allCommits = Lists.newArrayList(); RevCommit expectedCommit = null; for (Feature f : features) { insertAndAdd(f); String id = f.getIdentifier().getID(); final RevCommit commit = geogig.command(CommitOp.class).call(); if (id.equals(lines1.getIdentifier().getID())) { expectedCommit = commit; } allCommits.add(commit); } String path = NodeRef.appendChild(linesName, lines1.getIdentifier().getID()); List<RevCommit> feature2_1Commits = toList(logOp.addPath(path).call()); assertEquals(1, feature2_1Commits.size()); assertEquals(Collections.singletonList(expectedCommit), feature2_1Commits); }
@Test public void testPathFilterSingleFeature() throws Exception { List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3); List<RevCommit> allCommits = Lists.newArrayList(); RevCommit expectedCommit = null; for (Feature f : features) { insertAndAdd(f); String id = f.getIdentifier().getID(); final RevCommit commit = geogig.command(CommitOp.class).call(); if (id.equals(lines1.getIdentifier().getID())) { expectedCommit = commit; } allCommits.add(commit); } String path = NodeRef.appendChild(linesName, lines1.getIdentifier().getID()); List<RevCommit> feature2_1Commits = toList(logOp.addPath(path).call()); assertEquals(1, feature2_1Commits.size()); assertEquals(Collections.singletonList(expectedCommit), feature2_1Commits); }
@Test public void testMultiplePaths() throws Exception { List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3); List<RevCommit> allCommits = Lists.newArrayList(); RevCommit expectedLineCommit = null; RevCommit expectedPointCommit = null; for (Feature f : features) { insertAndAdd(f); String id = f.getIdentifier().getID(); final RevCommit commit = geogig.command(CommitOp.class).call(); if (id.equals(lines1.getIdentifier().getID())) { expectedLineCommit = commit; } else if (id.equals(points1.getIdentifier().getID())) { expectedPointCommit = commit; } allCommits.add(commit); } String linesPath = NodeRef.appendChild(linesName, lines1.getIdentifier().getID()); String pointsPath = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); List<RevCommit> feature2_1Commits = toList(logOp.addPath(linesPath).call()); List<RevCommit> featureCommits = toList(logOp.addPath(pointsPath).call()); assertEquals(1, feature2_1Commits.size()); assertEquals(2, featureCommits.size()); assertEquals(Collections.singletonList(expectedLineCommit), feature2_1Commits); assertEquals(true, featureCommits.contains(expectedPointCommit) && featureCommits.contains(expectedLineCommit)); }
@Test public void testMultiplePaths() throws Exception { List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3); List<RevCommit> allCommits = Lists.newArrayList(); RevCommit expectedLineCommit = null; RevCommit expectedPointCommit = null; for (Feature f : features) { insertAndAdd(f); String id = f.getIdentifier().getID(); final RevCommit commit = geogig.command(CommitOp.class).call(); if (id.equals(lines1.getIdentifier().getID())) { expectedLineCommit = commit; } else if (id.equals(points1.getIdentifier().getID())) { expectedPointCommit = commit; } allCommits.add(commit); } String linesPath = NodeRef.appendChild(linesName, lines1.getIdentifier().getID()); String pointsPath = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); List<RevCommit> feature2_1Commits = toList(logOp.addPath(linesPath).call()); List<RevCommit> featureCommits = toList(logOp.addPath(pointsPath).call()); assertEquals(1, feature2_1Commits.size()); assertEquals(2, featureCommits.size()); assertEquals(Collections.singletonList(expectedLineCommit), feature2_1Commits); assertEquals(true, featureCommits.contains(expectedPointCommit) && featureCommits.contains(expectedLineCommit)); }