use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class RepositoriesViewContentProvider method createTagNode.
private TagNode createTagNode(RepositoryTreeNode parentNode, Repository repo, Ref ref, RevObject revObject, RevObject peeledObject) {
boolean annotated = (revObject instanceof RevTag);
if (peeledObject instanceof RevCommit) {
RevCommit commit = (RevCommit) peeledObject;
String id = commit.getId().name();
String message = commit.getShortMessage();
return new TagNode(parentNode, repo, ref, annotated, id, message);
} else {
// $NON-NLS-1$ //$NON-NLS-2$
return new TagNode(parentNode, repo, ref, annotated, "", "");
}
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class RepositoriesViewContentProvider method getTagsChildren.
private Object[] getTagsChildren(RepositoryTreeNode parentNode, Repository repo) {
List<RepositoryTreeNode<Ref>> nodes = new ArrayList<>();
try (RevWalk walk = new RevWalk(repo)) {
walk.setRetainBody(true);
Map<String, Ref> tagRefs = getRefs(repo, Constants.R_TAGS);
for (Ref tagRef : tagRefs.values()) {
ObjectId objectId = tagRef.getLeaf().getObjectId();
RevObject revObject = walk.parseAny(objectId);
RevObject peeledObject = walk.peel(revObject);
TagNode tagNode = createTagNode(parentNode, repo, tagRef, revObject, peeledObject);
nodes.add(tagNode);
}
} catch (IOException e) {
return handleException(e, parentNode);
}
return nodes.toArray();
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class RepositoriesViewLabelProvider method decorateImage.
private Image decorateImage(final Image image, Object element) {
RepositoryTreeNode node = (RepositoryTreeNode) element;
switch(node.getType()) {
case TAG:
// fall through
case ADDITIONALREF:
// fall through
case REF:
// if the branch or tag is checked out,
// we want to decorate the corresponding
// node with a little check indicator
String refName = ((Ref) node.getObject()).getName();
Ref leaf = ((Ref) node.getObject()).getLeaf();
String branchName;
String compareString;
try {
branchName = node.getRepository().getFullBranch();
if (branchName == null)
return image;
if (refName.startsWith(Constants.R_HEADS)) {
// local branch: HEAD would be on the branch
compareString = refName;
} else if (refName.startsWith(Constants.R_TAGS)) {
// tag: HEAD would be on the commit id to which the tag is
// pointing
TagNode tagNode = (TagNode) node;
compareString = tagNode.getCommitId();
} else if (refName.startsWith(Constants.R_REMOTES)) {
// remote branch: HEAD would be on the commit id to which
// the branch is pointing
ObjectId id = node.getRepository().resolve(refName);
if (id == null)
return image;
try (RevWalk rw = new RevWalk(node.getRepository())) {
RevCommit commit = rw.parseCommit(id);
compareString = commit.getId().name();
}
} else if (refName.equals(Constants.HEAD)) {
return getDecoratedImage(image);
} else {
String leafname = leaf.getName();
if (leafname.startsWith(Constants.R_REFS) && leafname.equals(node.getRepository().getFullBranch())) {
return getDecoratedImage(image);
}
ObjectId objectId = leaf.getObjectId();
if (objectId != null && objectId.equals(node.getRepository().resolve(Constants.HEAD))) {
return getDecoratedImage(image);
}
// some other symbolic reference
return image;
}
} catch (IOException e1) {
return image;
}
if (compareString != null && compareString.equals(branchName)) {
return getDecoratedImage(image);
}
return image;
default:
return image;
}
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class PushTagsWizard method getRefSpecs.
private List<RefSpec> getRefSpecs() {
List<RefSpec> specs = new ArrayList<>();
String prefix;
if (pushTagsPage.isForceUpdateSelected())
// $NON-NLS-1$
prefix = "+";
else
// $NON-NLS-1$
prefix = "";
for (TagNode tag : pushTagsPage.getSelectedTags()) {
String refName = tag.getObject().getName();
RefSpec spec = new RefSpec(prefix + refName);
specs.add(spec);
}
return specs;
}
Aggregations