builder.authorEmail(author.getEmail().orNull()); builder.authorTimestamp(author.getTimestamp()); builder.authorTimeZoneOffset(author.getTimeZoneOffset());
@Test public void testCommitSerializationNoAuthor() throws IOException { testCommit.author(null); testCommit.authorEmail(null); RevCommit commit = testCommit.build(); testCommit(commit); }
builder.authorTimestamp(timestamp); builder.author(authorName); builder.authorEmail(authorEmail); if (commitMessage != null) { builder.message(commitMessage);
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; } }
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; }
if (this.commit == null) { .authorEmail(resolveAuthorEmail())//
@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()); }
b.authorEmail("groldan@boundlessgeo.com"); b.committer("jdeolive"); b.committerEmail("jdeolive@boundlessgeo.com"); b.authorEmail(null); b.committerTimestamp(-1000L); b.committerTimeZoneOffset(-5);
@Test public void testNoAuthorTimeStamp() throws Exception { RevCommitBuilder b = RevCommit.builder(); b.author("groldan"); b.authorEmail("groldan@boundlessgeo.com"); b.committer("jdeolive"); b.committerEmail("jdeolive@boundlessgeo.com"); b.committerTimestamp(1000L); b.message("cool this works"); b.treeId(hashString("some tree id")); assertEquals(1000, b.build().getAuthor().getTimestamp()); }
@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()); }
builder.author(author); String authorEmail = "groldan@boundlessgeo.com"; builder.authorEmail(authorEmail); builder.authorTimestamp(currentTime); builder.authorTimeZoneOffset(timeZoneOffset);
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); }
public void testBuildFull() throws Exception { RevCommitBuilder b = RevCommit.builder(); b.author("groldan"); b.authorEmail("groldan@boundlessgeo.com"); b.committer("jdeolive"); b.committerEmail("jdeolive@boundlessgeo.com");