@Test public void testCommitSerializationNoParents() throws IOException { testCommit.parentIds(null); RevCommit commit = testCommit.build(); testCommit(commit); }
builder.parentIds(parentIds); builder.treeId(ObjectId.valueOf(tree)); RevCommit commit = builder.build();
builder.parentIds(newParents); builder.treeId(newTreeId);
builder.parentIds(Lists.newArrayList(filteredParents)); builder.treeId(endTree); if (message == null) {
long timestamp = context.platform().currentTimeMillis(); builder.parentIds(Arrays.asList(commitId)); builder.treeId(newTree.getId()); builder.committerTimestamp(timestamp);
@Test public void testCommitSerializationMultipleParents() throws IOException { testCommit.parentIds(ImmutableList.of(RevObjectTestSupport.hashString("parent1"), RevObjectTestSupport.hashString("parent2"), RevObjectTestSupport.hashString("parent3"), RevObjectTestSupport.hashString("parent4"))); RevCommit commit = testCommit.build(); testCommit(commit); }
public static List<RevCommit> createCommits(final int numCommits, @Nullable Platform platform) { LinkedList<RevCommit> commits = new LinkedList<>(); // much faster way of creating several fake commits than running CommitOp N times RevCommitBuilder builder = RevCommit.builder().platform(platform); long timeStamp = System.currentTimeMillis(); builder.author("gabe").authorEmail("gabe@example.com").committer("me") .committerEmail("me@too.com").committerTimestamp(timeStamp) .committerTimeZoneOffset(-1).authorTimestamp(timeStamp).authorTimeZoneOffset(-3) .treeId(RevTree.EMPTY_TREE_ID); ObjectId parent = null; for (int i = 1; i <= numCommits; i++) { ++timeStamp; builder.authorTimestamp(timeStamp).committerTimestamp(timeStamp); List<ObjectId> parents = parent == null ? null : ImmutableList.of(parent); RevCommit commit = builder.parentIds(parents).message("commit " + i).build(); commits.addFirst(commit); parent = commit.getId(); } return commits; } }
builder.parentIds(Lists.newArrayList(parents)); builder.treeId(commit.getTreeId()); long timestamp = platform.currentTimeMillis();
private RevCommitBuilder testCommit(ObjectId treeId, String author, String authorEmail, long authorTimestamp, String committer, String committerEmail, long committerTimestamp, String message, ObjectId... parentIds) { RevCommitBuilder b = RevCommit.builder(); b.treeId(treeId); b.author(author); b.authorEmail(authorEmail); b.committer(committer); b.committerEmail(committerEmail); b.message(message); b.authorTimestamp(authorTimestamp); b.committerTimestamp(committerTimestamp); if (parentIds != null) { b.parentIds(Lists.newArrayList(parentIds)); } return b; }
@Test public void testPassingNullToSetParentIds() throws Exception { RevCommitBuilder b = RevCommit.builder(); b.author("groldan"); b.authorEmail("groldan@boundlessgeo.com"); b.committer("jdeolive"); b.committerEmail("jdeolive@boundlessgeo.com"); b.message("cool this works"); b.authorTimestamp(1000L); ObjectId treeId = hashString("fake tree content"); b.treeId(treeId); b.parentIds(null); assertEquals(ImmutableList.of(), b.build().getParentIds()); }
@Test public void testNoMessage() throws Exception { RevCommitBuilder b = RevCommit.builder(); b.author("groldan"); b.authorEmail("groldan@boundlessgeo.com"); b.committer("jdeolive"); b.committerEmail("jdeolive@boundlessgeo.com"); b.message(null); b.authorTimestamp(1000L); ObjectId treeId = hashString("fake tree content"); b.treeId(treeId); ObjectId parentId1 = hashString("fake parent content 1"); ObjectId parentId2 = hashString("fake parent content 2"); List<ObjectId> parentIds = ImmutableList.of(parentId1, parentId2); b.parentIds(parentIds); assertEquals(null, b.message()); RevCommit commit2 = b.build(); assertEquals("", commit2.getMessage()); }
ObjectId parent2 = RevObjectTestSupport.hashString("Parent 2 of fake commit"); List<ObjectId> parents = Arrays.asList(parent1, parent2); builder.parentIds(parents);
private void createCommit(RevCommit commit) { // write new tree ObjectId newTreeId = command(WriteTree2.class).call(); long timestamp = platform().currentTimeMillis(); String committerName = resolveCommitter(); String committerEmail = resolveCommitterEmail(); // Create new commit RevCommitBuilder builder = RevCommit.builder(); builder.parentIds(Arrays.asList(revertHead)); builder.treeId(newTreeId); builder.committerTimestamp(timestamp); builder.message( "Revert '" + commit.getMessage() + "'\nThis reverts " + commit.getId().toString()); builder.committer(committerName); builder.committerEmail(committerEmail); builder.author(committerName); builder.authorEmail(committerEmail); RevCommit newCommit = builder.build(); objectDatabase().put(newCommit); revertHead = newCommit.getId(); command(UpdateRef.class).setName(currentBranch).setNewValue(revertHead).call(); command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(currentBranch).call(); workingTree().updateWorkHead(newTreeId); stagingArea().updateStageHead(newTreeId); }
@Test public void testCommitBuilder() throws Exception { RevCommitBuilder b = RevCommit.builder(); b.author("groldan"); b.authorEmail("groldan@boundlessgeo.com"); b.committer("jdeolive"); b.committerEmail("jdeolive@boundlessgeo.com"); b.message("cool this works"); b.authorTimestamp(1000L); ObjectId treeId = hashString("fake tree content"); b.treeId(treeId); ObjectId parentId1 = hashString("fake parent content 1"); ObjectId parentId2 = hashString("fake parent content 2"); List<ObjectId> parentIds = ImmutableList.of(parentId1, parentId2); b.parentIds(parentIds); RevCommit commit1 = b.build(); RevCommitBuilder builder = RevCommit.builder().init(commit1); assertEquals("groldan", builder.author()); assertEquals("jdeolive", builder.committer()); assertEquals("groldan@boundlessgeo.com", builder.authorEmail()); assertEquals("jdeolive@boundlessgeo.com", builder.committerEmail()); assertEquals(commit1.getMessage(), builder.message()); assertEquals(commit1.getParentIds(), builder.parentIds()); assertEquals(commit1.getTreeId(), builder.treeId()); assertEquals(commit1.getAuthor().getTimestamp(), builder.authorTimestamp().longValue()); RevCommit commit2 = builder.build(); assertEquals(commit1, commit2); }
ObjectId parentId2 = hashString("fake parent content 2"); List<ObjectId> parentIds = ImmutableList.of(parentId1, parentId2); b.parentIds(parentIds);
cb.parentIds(ImmutableList.of(masterCommit3.getId(), branchCommit2.getId())); cb.message("mergeCommit"); cb.author("groldan");