private CommitBuilder testCommit(ObjectId treeId, String author, String authorEmail, long authorTimestamp, String committer, String committerEmail, long committerTimestamp, String message, ObjectId... parentIds) { CommitBuilder b = new CommitBuilder(); b.setTreeId(treeId); b.setAuthor(author); b.setAuthorEmail(authorEmail); b.setCommitter(committer); b.setCommitterEmail(committerEmail); b.setMessage(message); b.setAuthorTimestamp(authorTimestamp); b.setCommitterTimestamp(committerTimestamp); if (parentIds != null) { b.setParentIds(Lists.newArrayList(parentIds)); } return b; }
@Test public void testCommitBuilder() throws Exception { CommitBuilder b = new CommitBuilder(); b.setAuthor("groldan"); b.setAuthorEmail("groldan@boundlessgeo.com"); b.setCommitter("jdeolive"); b.setCommitterEmail("jdeolive@boundlessgeo.com"); b.setMessage("cool this works"); b.setAuthorTimestamp(1000); b.setTreeId(treeId); b.setParentIds(parentIds); RevCommit commit1 = b.build(); CommitBuilder builder = new CommitBuilder(commit1); assertEquals("groldan", builder.getAuthor()); assertEquals("jdeolive", builder.getCommitter()); assertEquals("groldan@boundlessgeo.com", builder.getAuthorEmail()); assertEquals("jdeolive@boundlessgeo.com", builder.getCommitterEmail()); assertEquals(commit1.getMessage(), builder.getMessage()); assertEquals(commit1.getParentIds(), builder.getParentIds()); assertEquals(commit1.getTreeId(), builder.getTreeId()); assertEquals(commit1.getAuthor().getTimestamp(), builder.getAuthorTimestamp()); RevCommit commit2 = builder.build();
@Test public void testNoAuthorTimeStamp() throws Exception { CommitBuilder b = new CommitBuilder(); b.setAuthor("groldan"); b.setAuthorEmail("groldan@boundlessgeo.com"); b.setCommitter("jdeolive"); b.setCommitterEmail("jdeolive@boundlessgeo.com"); b.setCommitterTimestamp(1000); b.setMessage("cool this works"); assertEquals(1000, b.getAuthorTimestamp()); }
@Test public void testCommitSerializationNoCommitter() throws IOException { testCommit.setCommitter(null); testCommit.setCommitterEmail(null); RevCommit commit = testCommit.build(); testCommit(commit); }
.setDiffSupplier(Suppliers.ofInstance(changes)).call(); CommitBuilder builder = new CommitBuilder(commit); builder.setParentIds(newParents); builder.setTreeId(newTreeId); RevCommit mapped = builder.build(); repository.objectDatabase().put(mapped); return mapped;
parents.addAll(secondaryParents); ObjectId endTree = until.getTreeId(); CommitBuilder builder = new CommitBuilder(until); Collection<ObjectId> filteredParents = Collections2.filter(parents, new Predicate<ObjectId>() { builder.setParentIds(Lists.newArrayList(filteredParents)); builder.setTreeId(endTree); if (message == null) { message = since.getMessage(); builder.setMessage(message); builder.setCommitter(resolveCommitter()); builder.setCommitterEmail(resolveCommitterEmail()); builder.setCommitterTimestamp(timestamp); builder.setCommitterTimeZoneOffset(platform.timeZoneOffset(timestamp)); builder.setAuthorTimestamp(until.getAuthor().getTimestamp()); RevCommit newCommit = builder.build(); repository.objectDatabase().put(newCommit);
CommitBuilder builder = new CommitBuilder(); builder.setParentIds(Lists.newArrayList(newCommitObjectId)); builder.setTreeId(newRoot.getId()); builder.setAuthor(authorName.orNull()); builder.setAuthorEmail(authorEmail.orNull()); builder.setMessage(commitMessage .or("Reverted changes made to " + featurePath + " at " + newCommitId.toString())); RevCommit mapped = builder.build(); Repository repository = context.getRepository(); repository.objectDatabase().put(mapped);
ObjectId head = squashedId; for (RevCommit commit : commits) { CommitBuilder builder = new CommitBuilder(commit); Collection<ObjectId> parents = Collections2.transform(commit.getParentIds(), (id) -> { if (replacedCommits.containsKey(id)) { builder.setParentIds(Lists.newArrayList(parents)); builder.setTreeId(commit.getTreeId()); long timestamp = platform.currentTimeMillis(); builder.setCommitterTimestamp(timestamp); builder.setCommitterTimeZoneOffset(platform.timeZoneOffset(timestamp)); RevCommit newCommit = builder.build(); replacedCommits.put(commit.getId(), newCommit.getId()); objectDatabase().put(newCommit);
private RevTree createHeadTree(NodeRef... treeRefs) { RevTree root = createFromRefs(objectDb, treeRefs); objectDb.put(root); CommitBuilder cb = new CommitBuilder(geogig.getPlatform()); ObjectId treeId = root.getId(); RevCommit commit = cb.setTreeId(treeId).setCommitter("Gabriel Roldan") .setAuthor("Gabriel Roldan").build(); objectDb.put(commit); SymRef head = (SymRef) geogig.command(RefParse.class).setName(Ref.HEAD).call().get(); final String currentBranch = head.getTarget(); geogig.command(UpdateRef.class).setName(currentBranch).setNewValue(commit.getId()).call(); verifyRepositoryTree(NodeRef.ROOT, treeId); verifyTreeStructure(treeId, treeRefs); return root; }
@Test public void testCommitSerializationNoAuthor() throws IOException { testCommit.setAuthor(null); testCommit.setAuthorEmail(null); RevCommit commit = testCommit.build(); testCommit(commit); }
@Test public void testCommitSerializationMultipleLinesMessage() throws IOException { testCommit.setMessage("this\n is a \n multiple lines\n message"); RevCommit commit = testCommit.build(); testCommit(commit); }
@Test public void testCommitSerializationNoParents() throws IOException { testCommit.setParentIds(null); RevCommit commit = testCommit.build(); testCommit(commit); }
public void testBuildEmpty() throws Exception { CommitBuilder b = new CommitBuilder(); try { b.build(); fail("expected IllegalStateException on null tree id"); } catch (IllegalStateException e) { assertTrue(e.getMessage().contains("tree")); } }
@Test public void testCommitSerialization() throws IOException { RevCommit commit = testCommit.build(); testCommit(commit); }
CommitBuilder builder = new CommitBuilder(commit); List<ObjectId> newParents = new LinkedList<ObjectId>(); for (ObjectId parentCommitId : commit.getParentIds()) { newParents.add(graphDatabase.getMapping(parentCommitId)); builder.setParentIds(newParents); builder.setTreeId(newTreeId); RevCommit mapped = builder.build(); objectDatabase.put(mapped); CommitBuilder builder = new CommitBuilder(commit); List<ObjectId> newParents = new LinkedList<ObjectId>(); for (ObjectId parentCommitId : commit.getParentIds()) { newParents.add(graphDatabase.getMapping(parentCommitId)); builder.setParentIds(newParents); builder.setTreeId(rootTree.getId()); builder.setMessage(PLACEHOLDER_COMMIT_MESSAGE); RevCommit mapped = builder.build(); objectDatabase.put(mapped);
CommitBuilder builder = new CommitBuilder(commitToApply); builder.setParentIds(Arrays.asList(rebaseHead)); builder.setTreeId(newTreeId); builder.setCommitterTimestamp(timestamp); builder.setCommitterTimeZoneOffset(platform.timeZoneOffset(timestamp)); RevCommit newCommit = builder.build(); repository.objectDatabase().put(newCommit); CommitBuilder builder = new CommitBuilder(commitToApply); builder.setParentIds(Arrays.asList(rebaseHead)); builder.setTreeId(newTreeId); builder.setCommitterTimestamp(timestamp); builder.setCommitterTimeZoneOffset(platform.timeZoneOffset(timestamp)); RevCommit newCommit = builder.build(); repository.objectDatabase().put(newCommit);
@Test public void testCommitSerializationNoMessage() throws IOException { testCommit.setMessage(null); RevCommit commit = testCommit.build(); testCommit(commit); }
@Test public void testCommitSerializationMultipleParents() throws IOException { testCommit.setParentIds(ImmutableList.of(RevObjectTestSupport.hashString("parent1"), RevObjectTestSupport.hashString("parent2"), RevObjectTestSupport.hashString("parent3"), RevObjectTestSupport.hashString("parent4"))); RevCommit commit = testCommit.build(); testCommit(commit); }
testCommit.build(), //
@Test public void testPassingNullToSetParentIds() throws Exception { CommitBuilder b = new CommitBuilder(); b.setAuthor("groldan"); b.setAuthorEmail("groldan@boundlessgeo.com"); b.setCommitter("jdeolive"); b.setCommitterEmail("jdeolive@boundlessgeo.com"); b.setMessage("cool this works"); b.setAuthorTimestamp(1000); ObjectId treeId = RevObjectTestSupport.hashString("fake tree content"); b.setTreeId(treeId); b.setParentIds(null); assertEquals(ImmutableList.of(), b.getParentIds()); }