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


Java RefUpdate.getName方法代码示例

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


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

示例1: updateReference

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void updateReference(
    Repository repository,
    String refName,
    ObjectId currentObjectId,
    ObjectId targetObjectId,
    Timestamp timestamp)
    throws IOException {
  RefUpdate ru = repository.updateRef(refName);
  ru.setExpectedOldObjectId(currentObjectId);
  ru.setNewObjectId(targetObjectId);
  ru.setRefLogIdent(getRefLogIdent(timestamp));
  ru.setRefLogMessage("inline edit (amend)", false);
  ru.setForceUpdate(true);
  try (RevWalk revWalk = new RevWalk(repository)) {
    RefUpdate.Result res = ru.update(revWalk);
    if (res != RefUpdate.Result.NEW && res != RefUpdate.Result.FORCED) {
      throw new IOException(
          "cannot update "
              + ru.getName()
              + " in "
              + repository.getDirectory()
              + ": "
              + ru.getResult());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:ChangeEditModifier.java

示例2: getCommand

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public static ReceiveCommand getCommand(RefUpdate update, ReceiveCommand.Type type) {
  return new ReceiveCommand(
      update.getExpectedOldObjectId(), update.getNewObjectId(), update.getName(), type);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:5,代码来源:RefOperationValidators.java

示例3: commit

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void commit(final Repository repo,
                    final RevCommit original,
                    final BiFunction fun) throws IOException {
    try (final ObjectReader reader = repo.newObjectReader();
         final ObjectInserter inserter = repo.newObjectInserter();
         final RevWalk rw = new RevWalk(reader)) {

        final RefTreeDatabase refdb = (RefTreeDatabase) repo.getRefDatabase();
        final RefDatabase bootstrap = refdb.getBootstrap();
        final RefUpdate refUpdate = bootstrap.newUpdate(refdb.getTxnCommitted(),
                                                        false);

        final CommitBuilder cb = new CommitBuilder();
        final Ref ref = bootstrap.exactRef(refdb.getTxnCommitted());
        final RefTree tree;
        if (ref != null && ref.getObjectId() != null) {
            tree = RefTree.read(reader,
                                rw.parseTree(ref.getObjectId()));
            cb.setParentId(ref.getObjectId());
            refUpdate.setExpectedOldObjectId(ref.getObjectId());
        } else {
            tree = RefTree.newEmptyTree();
            refUpdate.setExpectedOldObjectId(ObjectId.zeroId());
        }

        if (fun.apply(reader,
                      tree)) {
            final Ref ref2 = bootstrap.exactRef(refdb.getTxnCommitted());
            if (ref2 == null || ref2.getObjectId().equals(ref != null ? ref.getObjectId() : null)) {
                cb.setTreeId(tree.writeTree(inserter));
                if (original != null) {
                    cb.setAuthor(original.getAuthorIdent());
                    cb.setCommitter(original.getAuthorIdent());
                } else {
                    final PersonIdent personIdent = new PersonIdent("user",
                                                                    "[email protected]");
                    cb.setAuthor(personIdent);
                    cb.setCommitter(personIdent);
                }
                refUpdate.setNewObjectId(inserter.insert(cb));
                inserter.flush();
                final RefUpdate.Result result = refUpdate.update(rw);
                switch (result) {
                    case NEW:
                    case FAST_FORWARD:
                        break;
                    default:
                        throw new RuntimeException(repo.getDirectory() + " -> " + result.toString() + " : " + refUpdate.getName());
                }
                final File commited = new File(repo.getDirectory(),
                                               refdb.getTxnCommitted());
                final File accepted = new File(repo.getDirectory(),
                                               refdb.getTxnNamespace() + "accepted");
                Files.copy(commited.toPath(),
                           accepted.toPath(),
                           StandardCopyOption.REPLACE_EXISTING);
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:61,代码来源:RefTreeUpdateCommand.java


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