use of org.eclipse.jgit.revplot.PlotCommit in project egit by eclipse.
the class CommitGraphTable method doCopy.
private void doCopy() {
final ISelection s = table.getSelection();
if (s.isEmpty() || !(s instanceof IStructuredSelection))
return;
final IStructuredSelection iss = (IStructuredSelection) s;
final Iterator<PlotCommit> itr = iss.iterator();
final StringBuilder r = new StringBuilder();
while (itr.hasNext()) {
final PlotCommit d = itr.next();
if (r.length() > 0)
r.append(LINESEP);
r.append(d.getId().name());
}
if (clipboard == null || clipboard.isDisposed())
return;
clipboard.setContents(new Object[] { r.toString() }, new Transfer[] { TextTransfer.getInstance() }, DND.CLIPBOARD);
}
use of org.eclipse.jgit.revplot.PlotCommit in project egit by eclipse.
the class GitPropertyTester method hasRef.
private boolean hasRef(IRepositoryCommit commit, Collection<String> names) {
Repository repository = commit.getRepository();
if (repository == null) {
return false;
}
RevCommit revCommit = commit.getRevCommit();
if (revCommit instanceof PlotCommit) {
int n = ((PlotCommit) revCommit).getRefCount();
for (int i = 0; i < n; i++) {
Ref ref = ((PlotCommit) revCommit).getRef(i);
for (String name : names) {
if (ref.getName().startsWith(name)) {
return true;
}
}
}
} else {
try {
ObjectId selectedId = commit.getRevCommit().getId();
for (String name : names) {
for (Ref branch : repository.getRefDatabase().getRefs(name).values()) {
ObjectId objectId = branch.getLeaf().getObjectId();
if (objectId != null && objectId.equals(selectedId)) {
return true;
}
}
}
} catch (IOException e) {
// ignore here
}
}
return false;
}
use of org.eclipse.jgit.revplot.PlotCommit in project egit by eclipse.
the class GitHistoryPage method attachCommitSelectionChanged.
private void attachCommitSelectionChanged() {
graph.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
final ISelection s = event.getSelection();
if (s.isEmpty() || !(s instanceof IStructuredSelection)) {
commentViewer.setInput(null);
fileViewer.setInput(null);
return;
}
final IStructuredSelection sel = ((IStructuredSelection) s);
if (sel.size() > 1) {
commentViewer.setInput(null);
fileViewer.setInput(null);
return;
}
if (input == null) {
return;
}
final PlotCommit<?> c = (PlotCommit<?>) sel.getFirstElement();
commentViewer.setInput(c);
final PlotWalk walk = new PlotWalk(input.getRepository());
try {
final RevCommit unfilteredCommit = walk.parseCommit(c);
for (RevCommit parent : unfilteredCommit.getParents()) walk.parseBody(parent);
fileViewer.setInput(unfilteredCommit);
} catch (IOException e) {
fileViewer.setInput(c);
} finally {
walk.dispose();
}
if (input.getSingleFile() != null)
fileViewer.selectFirstInterestingElement();
}
});
commentViewer.addCommitNavigationListener(new CommitNavigationListener() {
@Override
public void showCommit(final RevCommit c) {
graph.selectCommit(c);
}
});
}
use of org.eclipse.jgit.revplot.PlotCommit in project egit by eclipse.
the class DeleteTagOnCommitHandler method getTagsOfCommit.
private List<Ref> getTagsOfCommit(IStructuredSelection selection) {
final List<Ref> tagsOfCommit = new ArrayList<>();
if (selection.isEmpty())
return tagsOfCommit;
PlotCommit commit = (PlotCommit) selection.getFirstElement();
for (int i = 0; i < commit.getRefCount(); i++) {
Ref ref = commit.getRef(i);
if (ref.getName().startsWith(Constants.R_TAGS))
tagsOfCommit.add(ref);
}
return tagsOfCommit;
}
use of org.eclipse.jgit.revplot.PlotCommit in project egit by eclipse.
the class PushCommitHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
PlotCommit commit = (PlotCommit) getSelection(event).getFirstElement();
final Repository repo = getRepository(event);
try {
PushBranchWizard wizard = null;
Ref localBranch = null;
for (int i = 0; i < commit.getRefCount(); i++) {
Ref currentRef = commit.getRef(i);
if (localBranch == null && currentRef.getName().startsWith(Constants.R_HEADS))
localBranch = currentRef;
}
if (localBranch == null)
wizard = new PushBranchWizard(repo, commit.getId());
else
wizard = new PushBranchWizard(repo, localBranch);
PushWizardDialog dlg = new PushWizardDialog(HandlerUtil.getActiveShellChecked(event), wizard);
dlg.setHelpAvailable(true);
dlg.open();
} catch (Exception e) {
Activator.handleError(e.getMessage(), e, true);
}
return null;
}
Aggregations