Search in sources :

Example 1 with FinishFeatureDialog

use of org.eclipse.egit.gitflow.ui.internal.dialogs.FinishFeatureDialog in project egit by eclipse.

the class FeatureFinishHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        return error(UIText.Handlers_noGitflowRepositoryFound);
    }
    final String featureBranch;
    Repository repo = gfRepo.getRepository();
    try {
        featureBranch = repo.getBranch();
    } catch (IOException e) {
        return error(e.getMessage(), e);
    }
    Shell activeShell = HandlerUtil.getActiveShell(event);
    FinishFeatureDialog dialog = new FinishFeatureDialog(activeShell, featureBranch);
    if (dialog.open() != Window.OK) {
        return null;
    }
    final boolean squash = dialog.isSquash();
    boolean keepBranch = dialog.isKeepBranch();
    try {
        try {
            if (squash && !UIRepositoryUtils.handleUncommittedFiles(repo, activeShell))
                return null;
        } catch (GitAPIException e) {
            Activator.logError(e.getMessage(), e);
            return null;
        }
        final FeatureFinishOperation operation = new FeatureFinishOperation(gfRepo);
        operation.setSquash(squash);
        operation.setKeepBranch(keepBranch);
        JobUtil.scheduleUserWorkspaceJob(operation, UIText.FeatureFinishHandler_finishingFeature, JobFamilies.GITFLOW_FAMILY, new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent jobChangeEvent) {
                if (jobChangeEvent.getResult().isOK()) {
                    postMerge(gfRepo, featureBranch, squash, operation.getMergeResult());
                }
            }
        });
    } catch (WrongGitFlowStateException | CoreException | IOException | OperationCanceledException e) {
        return error(e.getMessage(), e);
    }
    return null;
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) FinishFeatureDialog(org.eclipse.egit.gitflow.ui.internal.dialogs.FinishFeatureDialog) IOException(java.io.IOException) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) Shell(org.eclipse.swt.widgets.Shell) FeatureFinishOperation(org.eclipse.egit.gitflow.op.FeatureFinishOperation) CoreException(org.eclipse.core.runtime.CoreException) WrongGitFlowStateException(org.eclipse.egit.gitflow.WrongGitFlowStateException) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Aggregations

IOException (java.io.IOException)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)1 WrongGitFlowStateException (org.eclipse.egit.gitflow.WrongGitFlowStateException)1 FeatureFinishOperation (org.eclipse.egit.gitflow.op.FeatureFinishOperation)1 FinishFeatureDialog (org.eclipse.egit.gitflow.ui.internal.dialogs.FinishFeatureDialog)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 Repository (org.eclipse.jgit.lib.Repository)1 Shell (org.eclipse.swt.widgets.Shell)1