Search in sources :

Example 1 with CherryPickCommand

use of org.eclipse.jgit.api.CherryPickCommand in project egit by eclipse.

the class CherryPickOperation method execute.

@Override
public void execute(IProgressMonitor m) throws CoreException {
    IWorkspaceRunnable action = new IWorkspaceRunnable() {

        @Override
        public void run(IProgressMonitor pm) throws CoreException {
            SubMonitor progress = SubMonitor.convert(pm, 2);
            progress.subTask(MessageFormat.format(CoreText.CherryPickOperation_cherryPicking, commit.name()));
            try (Git git = new Git(repo)) {
                CherryPickCommand command = git.cherryPick().include(commit.getId());
                MergeStrategy strategy = Activator.getDefault().getPreferredMergeStrategy();
                if (strategy != null) {
                    command.setStrategy(strategy);
                }
                result = command.call();
            } catch (GitAPIException e) {
                throw new TeamException(e.getLocalizedMessage(), e.getCause());
            }
            progress.worked(1);
            ProjectUtil.refreshValidProjects(ProjectUtil.getValidOpenProjects(repo), progress.newChild(1));
        }
    };
    ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, m);
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Git(org.eclipse.jgit.api.Git) MergeStrategy(org.eclipse.jgit.merge.MergeStrategy) CherryPickCommand(org.eclipse.jgit.api.CherryPickCommand) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Aggregations

IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 CherryPickCommand (org.eclipse.jgit.api.CherryPickCommand)1 Git (org.eclipse.jgit.api.Git)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 MergeStrategy (org.eclipse.jgit.merge.MergeStrategy)1 TeamException (org.eclipse.team.core.TeamException)1