return CommitBuilder.create(id, treeId, parentListBuilder.build(), author, committer, message);
public RevCommit readCommit(@Nullable ObjectId id, DataInput in) throws IOException { final ObjectId treeId = readObjectId(in); final int nParents = readUnsignedVarInt(in); final Builder<ObjectId> parentListBuilder = ImmutableList.builder(); for (int i = 0; i < nParents; i++) { ObjectId parentId = readObjectId(in); parentListBuilder.add(parentId); } final RevPerson author = readRevPerson(in); final RevPerson committer = readRevPerson(in); final String message = in.readUTF(); ObjectId commitId = id; if (id == null) { commitId = ObjectId.NULL; } RevCommit commit = CommitBuilder.create(commitId, treeId, parentListBuilder.build(), author, committer, message); if (id == null) { commitId = new HashObject().setObject(commit).call(); commit = CommitBuilder.create(commitId, treeId, parentListBuilder.build(), author, committer, message); } return commit; }
.of(RevObjectTestSupport.hashString("Parent 1")); ImmutableList<ObjectId> emptyParentIds = ImmutableList.of(); RevCommit commit = CommitBuilder.create(id, treeId, parentId, author, committer, message); RevCommit commit2 = CommitBuilder.create(RevObjectTestSupport.hashString("second commit"), treeId, parentId, author, committer, message); commit2 = CommitBuilder.create(id, RevObjectTestSupport.hashString("new test tree"), parentId, author, committer, message); commit2 = CommitBuilder.create(id, treeId, emptyParentIds, author, committer, message); commit2 = CommitBuilder.create(id, treeId, parentId, committer, committer, message); commit2 = CommitBuilder.create(id, treeId, parentId, author, author, message); commit2 = CommitBuilder.create(id, treeId, parentId, author, committer, "new message");
@Test public void testConstructorAndAccessors() { RevPerson committer = RevPersonBuilder.build("ksishmael", "kelsey.ishmael@lmnsolutions.com", 12345, 12345); RevPerson author = RevPersonBuilder.build("test", "test@email.com", 12345, 12345); ObjectId id = RevObjectTestSupport.hashString("new commit"); ObjectId treeId = RevObjectTestSupport.hashString("test tree"); String message = "This is a test commit"; ImmutableList<ObjectId> parentIds = ImmutableList .of(RevObjectTestSupport.hashString("Parent 1")); RevCommit commit = CommitBuilder.create(id, treeId, parentIds, author, committer, message); assertEquals(committer, commit.getCommitter()); assertEquals(author, commit.getAuthor()); assertEquals(id, commit.getId()); assertEquals(treeId, commit.getTreeId()); assertEquals(message, commit.getMessage()); assertEquals(parentIds, commit.getParentIds()); assertEquals(TYPE.COMMIT, commit.getType()); assertEquals(parentIds.get(0), commit.parentN(0).get()); parentIds = ImmutableList.of(); commit = CommitBuilder.create(id, treeId, parentIds, author, committer, message); assertEquals(Collections.EMPTY_LIST, commit.getParentIds()); assertEquals(Optional.absent(), commit.parentN(0)); }