Example usage for org.eclipse.jgit.api CherryPickResult getCherryPickedRefs

List of usage examples for org.eclipse.jgit.api CherryPickResult getCherryPickedRefs

Introduction

In this page you can find the example usage for org.eclipse.jgit.api CherryPickResult getCherryPickedRefs.

Prototype

public List<Ref> getCherryPickedRefs() 

Source Link

Document

Get the cherry-picked Ref s

Usage

From source file:org.eclipse.egit.ui.internal.commit.command.CherryPickHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    RevCommit commit = getSelectedItem(RevCommit.class, event);
    if (commit == null)
        return null;
    Repository repo = getSelectedItem(Repository.class, event);
    if (repo == null)
        return null;
    final Shell parent = getPart(event).getSite().getShell();

    if (!confirmCherryPick(parent, repo, commit))
        return null;

    final CherryPickOperation op = new CherryPickOperation(repo, commit);

    Job job = new Job(MessageFormat.format(UIText.CherryPickHandler_JobName, commit.name())) {
        @Override//from   www .j  av a 2 s . c  om
        protected IStatus run(IProgressMonitor monitor) {
            try {
                op.execute(monitor);
                CherryPickResult cherryPickResult = op.getResult();
                RevCommit newHead = cherryPickResult.getNewHead();
                if (newHead != null && cherryPickResult.getCherryPickedRefs().isEmpty())
                    showNotPerformedDialog(parent);
                if (newHead == null) {
                    CherryPickStatus status = cherryPickResult.getStatus();
                    switch (status) {
                    case CONFLICTING:
                        showConflictDialog(parent);
                        break;
                    case FAILED:
                        showFailure(cherryPickResult);
                        break;
                    case OK:
                        break;
                    }
                }
            } catch (CoreException e) {
                Activator.logError(UIText.CherryPickOperation_InternalError, e);
            }
            return Status.OK_STATUS;
        }

        @Override
        public boolean belongsTo(Object family) {
            if (JobFamilies.CHERRY_PICK.equals(family))
                return true;
            return super.belongsTo(family);
        }
    };
    job.setUser(true);
    job.setRule(op.getSchedulingRule());
    job.schedule();
    return null;
}