本文整理汇总了Java中org.eclipse.jgit.lib.ObjectId.name方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectId.name方法的具体用法?Java ObjectId.name怎么用?Java ObjectId.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.lib.ObjectId
的用法示例。
在下文中一共展示了ObjectId.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBlob
import org.eclipse.jgit.lib.ObjectId; //导入方法依赖的package包/类
/**
* Read blob content and cache result in repository in case the same blob
* content is requested again.
*
* We made this method thread-safe as we are using ForkJoinPool to calculate
* diffs of multiple blob changes concurrently, and this method will be
* accessed concurrently in that special case.
*
* @param blobIdent
* ident of the blob
* @return
* blob of specified blob ident
* @throws
* ObjectNotFoundException if blob of specified ident can not be found in repository
*
*/
public Blob getBlob(BlobIdent blobIdent) {
Preconditions.checkArgument(blobIdent.revision!=null && blobIdent.path!=null && blobIdent.mode!=null,
"Revision, path and mode of ident param should be specified");
Blob blob = getBlobCache().get(blobIdent);
if (blob == null) {
try (RevWalk revWalk = new RevWalk(getRepository())) {
ObjectId revId = getObjectId(blobIdent.revision);
RevTree revTree = revWalk.parseCommit(revId).getTree();
TreeWalk treeWalk = TreeWalk.forPath(getRepository(), blobIdent.path, revTree);
if (treeWalk != null) {
ObjectId blobId = treeWalk.getObjectId(0);
if (blobIdent.isGitLink()) {
String url = getSubmodules(blobIdent.revision).get(blobIdent.path);
if (url == null)
throw new ObjectNotFoundException("Unable to find submodule '" + blobIdent.path + "' in .gitmodules");
String hash = blobId.name();
blob = new Blob(blobIdent, blobId, new Submodule(url, hash).toString().getBytes());
} else if (blobIdent.isTree()) {
throw new NotFileException("Path '" + blobIdent.path + "' is a tree");
} else {
blob = new Blob(blobIdent, blobId, treeWalk.getObjectReader());
}
getBlobCache().put(blobIdent, blob);
} else {
throw new ObjectNotFoundException("Unable to find blob path '" + blobIdent.path + "' in revision '" + blobIdent.revision + "'");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return blob;
}
示例2: run
import org.eclipse.jgit.lib.ObjectId; //导入方法依赖的package包/类
@Override
protected void run () throws GitException {
Repository repository = getRepository();
ObjectId originalCommit = getOriginalCommit();
ObjectId head = getHead();
List<RebaseTodoLine> steps;
try {
switch (operation) {
case BEGIN:
// initialize sequencer and cherry-pick steps if there are
// more commits to cherry-pick
steps = prepareCommand(head);
// apply the selected steps
applySteps(steps, false);
break;
case ABORT:
// delete the sequencer and reset to the original head
if (repository.getRepositoryState() == RepositoryState.CHERRY_PICKING
|| repository.getRepositoryState() == RepositoryState.CHERRY_PICKING_RESOLVED) {
if (originalCommit == null) {
// maybe the sequencer is not created in that case simply reset to HEAD
originalCommit = head;
}
}
Utils.deleteRecursively(getSequencerFolder());
if (originalCommit != null) {
ResetCommand reset = new ResetCommand(repository, getClassFactory(),
originalCommit.name(), GitClient.ResetType.HARD, new DelegatingGitProgressMonitor(monitor), listener);
reset.execute();
}
result = createCustomResult(GitCherryPickResult.CherryPickStatus.ABORTED);
break;
case QUIT:
// used to reset the sequencer only
Utils.deleteRecursively(getSequencerFolder());
switch (repository.getRepositoryState()) {
case CHERRY_PICKING:
// unresolved conflicts
result = createResult(CherryPickResult.CONFLICT);
break;
case CHERRY_PICKING_RESOLVED:
result = createCustomResult(GitCherryPickResult.CherryPickStatus.UNCOMMITTED);
break;
default:
result = createCustomResult(GitCherryPickResult.CherryPickStatus.OK);
break;
}
break;
case CONTINUE:
switch (repository.getRepositoryState()) {
case CHERRY_PICKING:
// unresolved conflicts, cannot continue
result = createResult(CherryPickResult.CONFLICT);
break;
case CHERRY_PICKING_RESOLVED:
// cannot continue without manual commit
result = createCustomResult(GitCherryPickResult.CherryPickStatus.UNCOMMITTED);
break;
default:
// read steps from sequencer and apply them
// if sequencer is empty this will be a noop
steps = readTodoFile(repository);
applySteps(steps, true);
break;
}
break;
default:
throw new IllegalStateException("Unexpected operation " + operation.name());
}
} catch (GitAPIException | IOException ex) {
throw new GitException(ex);
}
}
示例3: getObjectName
import org.eclipse.jgit.lib.ObjectId; //导入方法依赖的package包/类
public String getObjectName(boolean mustExist) {
ObjectId objectId = getObjectId(mustExist);
return objectId!=null?objectId.name():null;
}