当前位置: 首页>>代码示例>>Java>>正文


Java CommitBuilder.addParentId方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.CommitBuilder.addParentId方法的典型用法代码示例。如果您正苦于以下问题:Java CommitBuilder.addParentId方法的具体用法?Java CommitBuilder.addParentId怎么用?Java CommitBuilder.addParentId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.CommitBuilder的用法示例。


在下文中一共展示了CommitBuilder.addParentId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
protected void save(PersonIdent ident, String msg) throws IOException, ConfigInvalidException {
  File path = getPath();
  if (path == null) {
    throw new IOException(project + " does not exist.");
  }

  try (Repository repo = new FileRepository(path);
      ObjectInserter i = repo.newObjectInserter();
      ObjectReader r = repo.newObjectReader();
      RevWalk rw = new RevWalk(r)) {
    inserter = i;
    reader = r;

    RevTree srcTree = revision != null ? rw.parseTree(revision) : null;
    newTree = readTree(srcTree);

    CommitBuilder commit = new CommitBuilder();
    commit.setAuthor(ident);
    commit.setCommitter(ident);
    commit.setMessage(msg);

    onSave(commit);

    ObjectId res = newTree.writeTree(inserter);
    if (res.equals(srcTree)) {
      return;
    }
    commit.setTreeId(res);

    if (revision != null) {
      commit.addParentId(revision);
    }
    ObjectId newRevision = inserter.insert(commit);
    updateRef(repo, ident, newRevision, "commit: " + msg);
    revision = rw.parseCommit(newRevision);
  } finally {
    inserter = null;
    reader = null;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:41,代码来源:VersionedMetaDataOnInit.java

示例2: writeSquashedCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private static RevCommit writeSquashedCommit(
    RevWalk rw, ObjectInserter inserter, RevCommit parent, RevCommit edit) throws IOException {
  CommitBuilder mergeCommit = new CommitBuilder();
  for (int i = 0; i < parent.getParentCount(); i++) {
    mergeCommit.addParentId(parent.getParent(i));
  }
  mergeCommit.setAuthor(parent.getAuthorIdent());
  mergeCommit.setMessage(edit.getFullMessage());
  mergeCommit.setCommitter(edit.getCommitterIdent());
  mergeCommit.setTreeId(edit.getTree());

  return rw.parseCommit(commit(inserter, mergeCommit));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:ChangeEditUtil.java

示例3: commit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private RevCommit commit(
    Repository repo,
    RevWalk rw,
    @Nullable InMemoryInserter tmpIns,
    ObjectInserter ins,
    String refName,
    ObjectId tree,
    RevCommit merge)
    throws IOException {
  rw.parseHeaders(merge);
  // For maximum stability, choose a single ident using the committer time of
  // the input commit, using the server name and timezone.
  PersonIdent ident =
      new PersonIdent(
          gerritIdent, merge.getCommitterIdent().getWhen(), gerritIdent.getTimeZone());
  CommitBuilder cb = new CommitBuilder();
  cb.setAuthor(ident);
  cb.setCommitter(ident);
  cb.setTreeId(tree);
  cb.setMessage("Auto-merge of " + merge.name() + '\n');
  for (RevCommit p : merge.getParents()) {
    cb.addParentId(p);
  }

  if (!save) {
    checkArgument(tmpIns != null);
    try (ObjectReader tmpReader = tmpIns.newReader();
        RevWalk tmpRw = new RevWalk(tmpReader)) {
      return tmpRw.parseCommit(tmpIns.insert(cb));
    }
  }

  checkArgument(tmpIns == null);
  checkArgument(!(ins instanceof InMemoryInserter));
  ObjectId commitId = ins.insert(cb);
  ins.flush();

  RefUpdate ru = repo.updateRef(refName);
  ru.setNewObjectId(commitId);
  ru.disableRefLog();
  ru.forceUpdate();
  return rw.parseCommit(commitId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:44,代码来源:AutoMerger.java


注:本文中的org.eclipse.jgit.lib.CommitBuilder.addParentId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。