本文整理匯總了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;
}