@Override protected Optional<RevFeatureType> _call() { Preconditions.checkState(refSpec != null, "ref spec has not been set."); final String fullRefspec; if (refSpec.contains(":")) { fullRefspec = refSpec; } else { fullRefspec = Ref.WORK_HEAD + ":" + refSpec; } final String ref = fullRefspec.substring(0, fullRefspec.indexOf(':')); final String path = fullRefspec.substring(fullRefspec.indexOf(':') + 1); ObjectId parentId = command(ResolveTreeish.class).setTreeish(ref).call().get(); Optional<RevTree> parent = command(RevObjectParse.class).setObjectId(parentId) .call(RevTree.class); if (!parent.isPresent()) { return Optional.absent(); } Optional<NodeRef> node = command(FindTreeChild.class).setParent(parent.get()) .setChildPath(path).call(); if (!node.isPresent()) { return Optional.absent(); } NodeRef found = node.get(); ObjectId metadataID = found.getMetadataId(); Optional<RevFeatureType> ft = command(RevObjectParse.class).setObjectId(metadataID) .call(RevFeatureType.class); return ft; } }
@Override protected Optional<RevFeatureType> _call() { Preconditions.checkState(refSpec != null, "ref spec has not been set."); final String fullRefspec; if (refSpec.contains(":")) { fullRefspec = refSpec; } else { fullRefspec = Ref.WORK_HEAD + ":" + refSpec; } final String ref = fullRefspec.substring(0, fullRefspec.indexOf(':')); final String path = fullRefspec.substring(fullRefspec.indexOf(':') + 1); ObjectId parentId = command(ResolveTreeish.class).setTreeish(ref).call().get(); Optional<RevTree> parent = command(RevObjectParse.class).setObjectId(parentId) .call(RevTree.class); if (!parent.isPresent()) { return Optional.absent(); } Optional<NodeRef> node = command(FindTreeChild.class).setParent(parent.get()) .setChildPath(path).call(); if (!node.isPresent()) { return Optional.absent(); } NodeRef found = node.get(); ObjectId metadataID = found.getMetadataId(); Optional<RevFeatureType> ft = command(RevObjectParse.class).setObjectId(metadataID) .call(RevFeatureType.class); return ft; } }