本文整理汇总了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());
}
}
}
示例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);
}
示例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);
}
}
}
}