public static List<RevCommit> createCommits(final int numCommits) { return createCommits(numCommits, (Platform) null); }
public static List<RevCommit> createCommits(final int numCommits) { return createCommits(numCommits, (Platform) null); }
public @Test void testAbortsOnAncestorOfShallowClone() { LinkedList<RevCommit> commits = new LinkedList<>(createCommits(100)); // a shallow clone will have it's eldest commit with a parent that doesn't exist, let's // simulate that here by not adding the first one to the ObjectStore RevCommit parentOfShallow = commits.removeLast(); RevCommit shallowCommit = commits.getLast(); assertEquals(parentOfShallow.getId(), shallowCommit.getParentIds().get(0)); repo.objectDatabase().putAll(commits.iterator()); repo.command(UpdateRef.class).setName(Ref.HEAD).setNewValue(commits.get(0).getId()).call(); RevParse revParse = repo.command(RevParse.class); Optional<ObjectId> shallow = revParse.setRefSpec("HEAD~98").call(); assertTrue(shallow.isPresent()); assertEquals(shallowCommit.getId(), shallow.get()); Optional<ObjectId> ancestorOfShallow = revParse.setRefSpec("HEAD~99").call(); assertFalse(ancestorOfShallow.isPresent()); }
public @Test void testPutAllUpdatesGraphDatabase() { ObjectDatabase db = db(); GraphDatabase graph = db.getGraphDatabase(); assertNotNull(graph); List<RevCommit> commits = createCommits(100); db.putAll(commits.iterator()); commits.forEach((c) -> assertTrue(c.getId().toString(), graph.exists(c.getId()))); }
public @Test void testPutAllUpdatesGraphDatabase() { ObjectDatabase db = db(); GraphDatabase graph = db.getGraphDatabase(); assertNotNull(graph); List<RevCommit> commits = createCommits(100); db.putAll(commits.iterator()); commits.forEach((c) -> assertTrue(c.getId().toString(), graph.exists(c.getId()))); }
public @Test void testAbortsOnAncestorOfShallowClone() { LinkedList<RevCommit> commits = new LinkedList<>(createCommits(100)); // a shallow clone will have it's eldest commit with a parent that doesn't exist, let's // simulate that here by not adding the first one to the ObjectStore RevCommit parentOfShallow = commits.removeLast(); RevCommit shallowCommit = commits.getLast(); assertEquals(parentOfShallow.getId(), shallowCommit.getParentIds().get(0)); repo.objectDatabase().putAll(commits.iterator()); repo.command(UpdateRef.class).setName(Ref.HEAD).setNewValue(commits.get(0).getId()).call(); RevParse revParse = repo.command(RevParse.class); Optional<ObjectId> shallow = revParse.setRefSpec("HEAD~98").call(); assertTrue(shallow.isPresent()); assertEquals(shallowCommit.getId(), shallow.get()); Optional<ObjectId> ancestorOfShallow = revParse.setRefSpec("HEAD~99").call(); assertFalse(ancestorOfShallow.isPresent()); }
public @Test void testPutUpdatesGraphDatabase() { ObjectDatabase db = db(); GraphDatabase graph = db.getGraphDatabase(); assertNotNull(graph); List<RevCommit> commits = createCommits(2); RevCommit c1 = commits.get(0); RevCommit c2 = commits.get(1); assertFalse(graph.exists(c1.getId())); assertFalse(graph.exists(c2.getId())); db.put(c1); db.put(c2); assertTrue(graph.exists(c1.getId())); assertTrue(graph.exists(c2.getId())); }
public @Test void testPutUpdatesGraphDatabase() { ObjectDatabase db = db(); GraphDatabase graph = db.getGraphDatabase(); assertNotNull(graph); List<RevCommit> commits = createCommits(2); RevCommit c1 = commits.get(0); RevCommit c2 = commits.get(1); assertFalse(graph.exists(c1.getId())); assertFalse(graph.exists(c2.getId())); db.put(c1); db.put(c2); assertTrue(graph.exists(c1.getId())); assertTrue(graph.exists(c2.getId())); }