b.setParentIds(parents); b.setAuthor(tmpAuthor(batch)); b.setCommitter(b.getAuthor());
/** * Create a new commit by explicitly specifying the content tree and the * parents. The commit message is not set and author/committer are set to * the current user. * * @param tree * the tree this commit should capture * @param parents * the list of parent commits * @return a new commit visible only within this merger's RevWalk. * @throws IOException */ private RevCommit createCommitForTree(ObjectId tree, List<RevCommit> parents) throws IOException { CommitBuilder c = new CommitBuilder(); c.setTreeId(tree); c.setParentIds(parents); c.setAuthor(mockAuthor(parents)); c.setCommitter(c.getAuthor()); return RevCommit.parse(walk, c.build()); }
cb.setParentId(curr); } else { cb.setParentIds(Collections.<ObjectId> emptyList());
static void commitNoteMap(Repository r, String ref, RevWalk walk, NoteMap map, RevCommit notesCommit, ObjectInserter inserter, String msg) throws IOException { // commit the note CommitBuilder builder = new CommitBuilder(); builder.setTreeId(map.writeTree(inserter)); builder.setAuthor(new PersonIdent(r)); builder.setCommitter(builder.getAuthor()); builder.setMessage(msg); if (notesCommit != null) builder.setParentIds(notesCommit); ObjectId commit = inserter.insert(builder); inserter.flush(); RefUpdate refUpdate = r.updateRef(ref); if (notesCommit != null) refUpdate.setExpectedOldObjectId(notesCommit); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.setNewObjectId(commit); refUpdate.update(walk); }
commit.setTreeId(treeId); if (headId != null) commit.setParentIds(headId); commit.setAuthor(author); commit.setCommitter(author);
untrackedBuilder.finish(); builder.setParentIds(new ObjectId[0]); builder.setTreeId(untrackedDirCache.writeTree(inserter)); builder.setMessage(MessageFormat.format(MSG_UNTRACKED,
commit.setMessage(message); commit.setParentIds(parents); commit.setTreeId(indexTreeId); ObjectId commitId = odi.insert(commit);
@Nonnull private static AnyObjectId insertCommit(@Nonnull String message, @Nonnull AnyObjectId treeId, @Nonnull PersonIdent author, @Nonnull PersonIdent committer, @Nonnull List<AnyObjectId> parents, @Nonnull ObjectInserter inserter) throws IOException { CommitBuilder builder = new CommitBuilder(); builder.setCommitter(committer); builder.setAuthor(author); builder.setMessage(message); builder.setTreeId(treeId); builder.setParentIds(parents); return inserter.insert(builder); }
@Nonnull private static ObjectId insertCommit(String message, AnyObjectId treeId, PersonIdent author, PersonIdent committer, List<? extends AnyObjectId> parents, ObjectInserter inserter) throws IOException { CommitBuilder builder = new CommitBuilder(); builder.setCommitter(committer); builder.setAuthor(author); builder.setMessage(message); builder.setTreeId(treeId); builder.setParentIds(parents); return inserter.insert(builder); }
@Nonnull private static ObjectId insertCommit(String message, AnyObjectId treeId, PersonIdent author, PersonIdent committer, List<? extends AnyObjectId> parents, ObjectInserter inserter) throws IOException { CommitBuilder builder = new CommitBuilder(); builder.setCommitter(committer); builder.setAuthor(author); builder.setMessage(message); builder.setTreeId(treeId); builder.setParentIds(parents); return inserter.insert(builder); }
public ObjectId createMergeCommit(Map<SubtreeConfig, RevCommit> parentCommits, String message) throws IOException { PersonIdent latestIdent = getLatestPersonIdent(parentCommits.values()); DirCache treeDirCache = createTreeDirCache(parentCommits, message); List<? extends ObjectId> parentIds = new ArrayList<>(parentCommits.values()); try (ObjectInserter inserter = repository.newObjectInserter()) { ObjectId treeId = treeDirCache.writeTree(inserter); PersonIdent repositoryUser = new PersonIdent(repository); PersonIdent ident = new PersonIdent(repositoryUser, latestIdent.getWhen().getTime(), latestIdent.getTimeZoneOffset()); CommitBuilder commitBuilder = new CommitBuilder(); commitBuilder.setTreeId(treeId); commitBuilder.setAuthor(ident); commitBuilder.setCommitter(ident); commitBuilder.setMessage(message); commitBuilder.setParentIds(parentIds); ObjectId mergeCommit = inserter.insert(commitBuilder); inserter.flush(); return mergeCommit; } }
private RevCommit createCommit( NoteMap map, PersonIdent author, String message, RevCommit... parents) throws IOException { CommitBuilder b = new CommitBuilder(); b.setTreeId(map.writeTree(inserter)); b.setAuthor(author); b.setCommitter(author); if (parents.length > 0) { b.setParentIds(parents); } b.setMessage(message); ObjectId commitId = inserter.insert(b); inserter.flush(); return revWalk.parseCommit(commitId); } }
/** * Create a new commit by explicitly specifying the content tree and the * parents. The commit message is not set and author/committer are set to * the current user. * * @param tree * the tree this commit should capture * @param parents * the list of parent commits * @return a new commit visible only within this merger's RevWalk. * @throws IOException */ private RevCommit createCommitForTree(ObjectId tree, List<RevCommit> parents) throws IOException { CommitBuilder c = new CommitBuilder(); c.setTreeId(tree); c.setParentIds(parents); c.setAuthor(mockAuthor(parents)); c.setCommitter(c.getAuthor()); return RevCommit.parse(walk, c.build()); }
/** * Create a new commit by explicitly specifying the content tree and the * parents. The commit message is not set and author/committer are set to * the current user. * * @param tree * the tree this commit should capture * @param parents * the list of parent commits * @return a new commit visible only within this merger's RevWalk. * @throws IOException */ private RevCommit createCommitForTree(ObjectId tree, List<RevCommit> parents) throws IOException { CommitBuilder c = new CommitBuilder(); c.setTreeId(tree); c.setParentIds(parents); c.setAuthor(mockAuthor(parents)); c.setCommitter(c.getAuthor()); return RevCommit.parse(walk, c.build()); }
/** * Creates a merged notes commit. */ private RevCommit createNotesCommit(NoteMap map, ObjectInserter inserter, RevWalk revWalk, String message, RevCommit... parents) throws IOException { CommitBuilder commitBuilder = new CommitBuilder(); commitBuilder.setTreeId(map.writeTree(inserter)); commitBuilder.setAuthor(author); commitBuilder.setCommitter(author); if (parents.length > 0) { commitBuilder.setParentIds(parents); } commitBuilder.setMessage(message); ObjectId commitId = inserter.insert(commitBuilder); inserter.flush(); return revWalk.parseCommit(commitId); }
private CommitBuilder generateNewCommit(final Map<ObjectId, ObjectId> commitMap, final RevCommit commit, final ObjectId newCommitTree) { final CommitBuilder commitBuilder = new CommitBuilder(); commitBuilder.setAuthor(commit.getAuthorIdent()); commitBuilder.setCommitter(commit.getCommitterIdent()); commitBuilder.setTreeId(newCommitTree); commitBuilder.setMessage(commit.getFullMessage()); commitBuilder.setEncoding(commit.getEncoding()); final ObjectId[] newParentIds = closestMappedAncestorOrSelf(commitMap, commit.getParents()); if (newParentIds.length > 0) { commitBuilder.setParentIds(newParentIds); } return commitBuilder; }
private ObjectId writeCommit(final ObjectInserter inserter, final ObjectId commitTreeId, final ObjectId... parentIds) throws IOException { final CommitBuilder builder = new CommitBuilder(); builder.setAuthor(new PersonIdent("name", "name@example.com")); builder.setCommitter(new PersonIdent("name", "name@example.com")); builder.setTreeId(commitTreeId); builder.setMessage("merge commit"); builder.setParentIds(parentIds); final ObjectId commitId = inserter.insert(builder); return commitId; }
private ObjectId writeCommit(final ObjectInserter inserter, final ObjectId commitTreeId, final ObjectId... parentIds) throws IOException { final CommitBuilder builder = new CommitBuilder(); builder.setAuthor(new PersonIdent("name", "name@example.com")); builder.setCommitter(new PersonIdent("name", "name@example.com")); builder.setTreeId(commitTreeId); builder.setMessage("merge commit"); builder.setParentIds(parentIds); final ObjectId commitId = inserter.insert(builder); return commitId; }
private void commitNoteMap(RevWalk walk, NoteMap map, RevCommit notesCommit, ObjectInserter inserter, String msg) throws IOException { // commit the note CommitBuilder builder = new CommitBuilder(); builder.setTreeId(map.writeTree(inserter)); builder.setAuthor(new PersonIdent(repo)); builder.setCommitter(builder.getAuthor()); builder.setMessage(msg); if (notesCommit != null) builder.setParentIds(notesCommit); ObjectId commit = inserter.insert(builder); inserter.flush(); RefUpdate refUpdate = repo.updateRef(notesRef); if (notesCommit != null) refUpdate.setExpectedOldObjectId(notesCommit); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.setNewObjectId(commit); refUpdate.update(walk); }
private void commitNoteMap(RevWalk walk, NoteMap map, RevCommit notesCommit, ObjectInserter inserter, String msg) throws IOException { // commit the note CommitBuilder builder = new CommitBuilder(); builder.setTreeId(map.writeTree(inserter)); builder.setAuthor(new PersonIdent(repo)); builder.setCommitter(builder.getAuthor()); builder.setMessage(msg); if (notesCommit != null) builder.setParentIds(notesCommit); ObjectId commit = inserter.insert(builder); inserter.flush(); RefUpdate refUpdate = repo.updateRef(notesRef); if (notesCommit != null) refUpdate.setExpectedOldObjectId(notesCommit); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.setNewObjectId(commit); refUpdate.update(walk); }