Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.CommitBuilder


  }

  private static ObjectId createCommit(final NoteMap noteMap,
      final ObjectInserter inserter, final PersonIdent personIdent,
      final String message, final ObjectId... parents) throws IOException {
    final CommitBuilder b = new CommitBuilder();
    b.setTreeId(noteMap.writeTree(inserter));
    b.setAuthor(personIdent);
    b.setCommitter(personIdent);
    if (parents.length > 0) {
      b.setParentIds(parents);
    }
    b.setMessage(message);
    final ObjectId commitId = inserter.insert(b);
    inserter.flush();
    return commitId;
  }
View Full Code Here


      ed.finish();

      ObjectInserter oi = pdb.newObjectInserter();
      ObjectId tree = dc.writeTree(oi);

      final CommitBuilder commit = new CommitBuilder();
      commit.setTreeId(tree);
      commit.setParentIds(new ObjectId[] {currentCommitId});
      commit.setAuthor(author);
      commit.setCommitter(myIdent);
      commit.setMessage(msgbuf.toString());
      oi.insert(commit);

      ObjectId commitId = oi.idFor(Constants.OBJ_COMMIT, commit.build());

      final RefUpdate rfu = pdb.updateRef(subscriber.get());
      rfu.setForceUpdate(false);
      rfu.setNewObjectId(commitId);
      rfu.setExpectedOldObjectId(currentCommitId);
View Full Code Here

  private void createEmptyCommits(final Repository repo,
      final Project.NameKey project, final List<String> refs)
      throws IOException {
    ObjectInserter oi = repo.newObjectInserter();
    try {
      CommitBuilder cb = new CommitBuilder();
      cb.setTreeId(oi.insert(Constants.OBJ_TREE, new byte[] {}));
      cb.setAuthor(metaDataUpdateFactory.getUserPersonIdent());
      cb.setCommitter(serverIdent);
      cb.setMessage("Initial empty repository\n");

      ObjectId id = oi.insert(cb);
      oi.flush();

      for (String ref : refs) {
View Full Code Here

        final RevCommit originalCommit =
            revWalk.parseCommit(ObjectId.fromString(originalPatchSet
                .getRevision().get()));

        CommitBuilder rebasedCommitBuilder =
            rebaseCommit(git, originalCommit, branchTipCommit, myIdent);

        final ObjectInserter oi = git.newObjectInserter();
        final ObjectId rebasedCommitId;
        try {
View Full Code Here

          user.newCommitterIdent(myIdent.getWhen(), myIdent.getTimeZone());

      RevCommit parentToCommitToRevert = commitToRevert.getParent(0);
      revWalk.parseHeaders(parentToCommitToRevert);

      CommitBuilder revertCommit = new CommitBuilder();
      revertCommit.addParentId(commitToRevert);
      revertCommit.setTreeId(parentToCommitToRevert.getTree());
      revertCommit.setAuthor(authorIdent);
      revertCommit.setCommitter(myIdent);
      revertCommit.setMessage(message);

      final ObjectInserter oi = git.newObjectInserter();;
      ObjectId id;
      try {
        id = oi.insert(revertCommit);
View Full Code Here

            //
            newParents[k] = t.oldParents[k];
          }
        }

        final CommitBuilder newc = new CommitBuilder();
        newc.setTreeId(emptyTree);
        newc.setAuthor(new PersonIdent(me, new Date(t.commitTime)));
        newc.setCommitter(newc.getAuthor());
        newc.setParentIds(newParents);
        newc.setMessage("ORIGINAL " + t.oldId.name() + "\n"); //$NON-NLS-2$
        t.newId = oi.insert(newc);
        rewrites.put(t.oldId, t.newId);
        pm.update(1);
      }
    }
View Full Code Here

          // fail for example when the index contains unmerged paths
          // (unresolved conflicts)
          ObjectId indexTreeId = index.writeTree(odi);

          // Create a Commit object, populate it and write it
          CommitBuilder commit = new CommitBuilder();
          commit.setCommitter(committer);
          commit.setAuthor(author);
          commit.setMessage(message);

          commit.setParentIds(parents);
          commit.setTreeId(indexTreeId);
          ObjectId commitId = odi.insert(commit);
          odi.flush();

          RevWalk revWalk = new RevWalk(repo);
          try {
View Full Code Here

        TreeFormatter tree = new TreeFormatter();
        tree.append(".branch", FileMode.REGULAR_FILE, blobId);
        ObjectId treeId = odi.insert(tree);

        // Create a commit object
        CommitBuilder commit = new CommitBuilder();
        commit.setAuthor(author);
        commit.setCommitter(author);
        commit.setEncoding(Constants.CHARACTER_ENCODING);
        commit.setMessage(message);
        commit.setTreeId(treeId);

        // Insert the commit into the repository
        ObjectId commitId = odi.insert(commit);
        odi.flush();
View Full Code Here

        // create a merge commit and a reference to track the merge commit
        ObjectId treeId = merger.getResultTreeId();
        ObjectInserter odi = repository.newObjectInserter();
        try {
          // Create a commit object
          CommitBuilder commitBuilder = new CommitBuilder();
          commitBuilder.setCommitter(committer);
          commitBuilder.setAuthor(committer);
          commitBuilder.setEncoding(Constants.CHARSET);
          if (StringUtils.isEmpty(message)) {
            message = MessageFormat.format("merge {0} into {1}", srcTip.getName(), branchTip.getName());
          }
          commitBuilder.setMessage(message);
          commitBuilder.setParentIds(branchTip.getId(), srcTip.getId());
          commitBuilder.setTreeId(treeId);

          // Insert the merge commit into the repository
          ObjectId mergeCommitId = odi.insert(commitBuilder);
          odi.flush();
View Full Code Here

      // Create the in-memory index of the new/updated ticket
      ObjectId indexTreeId = index.writeTree(odi);

      // Create a commit object
      PersonIdent ident = new PersonIdent(author, "gitblit@localhost");
      CommitBuilder commit = new CommitBuilder();
      commit.setAuthor(ident);
      commit.setCommitter(ident);
      commit.setEncoding(Constants.ENCODING);
      commit.setMessage(message);
      commit.setParentId(headId);
      commit.setTreeId(indexTreeId);

      // Insert the commit into the repository
      ObjectId commitId = odi.insert(commit);
      odi.flush();
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.CommitBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.