use of org.eclipse.egit.gitflow.op.FeatureCheckoutOperation in project egit by eclipse.
the class FeatureCheckoutHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
if (gfRepo == null) {
return error(UIText.Handlers_noGitflowRepositoryFound);
}
Repository repository = gfRepo.getRepository();
final List<Ref> refs = gfRepo.getFeatureBranches();
FeatureBranchSelectionDialog dialog = new FeatureBranchSelectionDialog(HandlerUtil.getActiveShell(event), refs, UIText.FeatureCheckoutHandler_selectFeature, UIText.FeatureCheckoutHandler_localFeatures, Constants.R_HEADS + gfRepo.getConfig().getFeaturePrefix(), gfRepo);
if (dialog.open() != Window.OK) {
return null;
}
final Ref ref = dialog.getSelectedNode();
try {
String featureName = gfRepo.getFeatureBranchName(ref);
// TODO: consider using BranchOperationUI because checkout can take
// a long time on large repositories
FeatureCheckoutOperation checkoutOperation = new FeatureCheckoutOperation(gfRepo, featureName);
JobUtil.scheduleUserWorkspaceJob(checkoutOperation, UIText.FeatureCheckoutHandler_checkingOutFeature, JobFamilies.GITFLOW_FAMILY);
IJobManager jobMan = Job.getJobManager();
try {
jobMan.join(GITFLOW_FAMILY, null);
} catch (OperationCanceledException | InterruptedException e) {
return error(e.getMessage(), e);
}
CheckoutResult result = checkoutOperation.getResult();
if (!CheckoutResult.Status.OK.equals(result.getStatus())) {
Shell shell = HandlerUtil.getActiveShell(event);
if (!handleUncommittedFiles(gfRepo.getRepository(), shell, repository.getWorkTree().getName())) {
return Status.CANCEL_STATUS;
} else {
JobUtil.scheduleUserWorkspaceJob(checkoutOperation, UIText.FeatureCheckoutHandler_checkingOutFeature, JobFamilies.GITFLOW_FAMILY);
}
}
} catch (GitAPIException e) {
throw new RuntimeException(e);
}
return null;
}
Aggregations