use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class DevelopCompareHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
if (gfRepo == null) {
return error(UIText.Handlers_noGitflowRepositoryFound);
}
IResource[] selectedResources = GitFlowHandlerUtil.gatherResourceToOperateOn(event);
String revision;
try {
revision = GitFlowHandlerUtil.gatherRevision(event);
} catch (OperationCanceledException e) {
return null;
} catch (IOException e) {
throw new ExecutionException(e.getMessage(), e);
}
IWorkbenchPage workBenchPage = getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
CompareUtils.compare(selectedResources, gfRepo.getRepository(), HEAD, revision, true, workBenchPage);
} catch (IOException e) {
handleError(CompareWithRefAction_errorOnSynchronize, e, true);
}
return null;
}
use of org.eclipse.egit.gitflow.GitFlowRepository 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;
}
use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class FeatureFinishHandler method rewordCommitMessage.
private void rewordCommitMessage(Shell activeShell, final GitFlowRepository gfRepo) throws CoreException, IOException {
Repository repository = gfRepo.getRepository();
CommitHelper commitHelper = new CommitHelper(repository);
CommitMessageEditorDialog messageEditorDialog = new CommitMessageEditorDialog(activeShell, repository.readSquashCommitMsg(), UIText.FeatureFinishHandler_rewordSquashedCommitMessage);
if (Window.OK == messageEditorDialog.open()) {
String commitMessage = stripCommentLines(messageEditorDialog.getCommitMessage());
CommitOperation commitOperation = new CommitOperation(repository, commitHelper.getAuthor(), commitHelper.getCommitter(), commitMessage);
commitOperation.execute(null);
}
}
use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class FeatureTrackHandler 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 List<Ref> refs = new ArrayList<Ref>();
Shell activeShell = HandlerUtil.getActiveShell(event);
int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
FeatureListOperation featureListOperation = new FeatureListOperation(gfRepo, timeout);
JobUtil.scheduleUserWorkspaceJob(featureListOperation, UIText.FeatureTrackHandler_fetchingRemoteFeatures, GITFLOW_FAMILY);
IJobManager jobMan = Job.getJobManager();
try {
jobMan.join(GITFLOW_FAMILY, null);
} catch (OperationCanceledException | InterruptedException e) {
return error(e.getMessage(), e);
}
List<Ref> remoteFeatures = featureListOperation.getResult();
if (remoteFeatures.isEmpty()) {
MessageDialog.openInformation(activeShell, UIText.FeatureTrackHandler_noRemoteFeatures, UIText.FeatureTrackHandler_noRemoteFeaturesFoundOnTheConfiguredRemote);
}
refs.addAll(remoteFeatures);
FeatureBranchSelectionDialog dialog = new FeatureBranchSelectionDialog(HandlerUtil.getActiveShell(event), refs, UIText.FeatureCheckoutHandler_selectFeature, UIText.FeatureTrackHandler_remoteFeatures, R_REMOTES + DEFAULT_REMOTE_NAME + SEP + gfRepo.getConfig().getFeaturePrefix(), gfRepo);
if (dialog.open() != Window.OK) {
return Status.CANCEL_STATUS;
}
Ref ref = dialog.getSelectedNode();
FeatureTrackOperation featureTrackOperation = new FeatureTrackOperation(gfRepo, ref, timeout);
JobUtil.scheduleUserWorkspaceJob(featureTrackOperation, UIText.FeatureTrackHandler_trackingFeature, GITFLOW_FAMILY);
return null;
}
use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class GitFlowHandlerUtil method getRepository.
/**
* @param event
* @return Selected GitFlowRepository
*/
@Nullable
public static GitFlowRepository getRepository(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IStructuredSelection structuredSelection = SelectionUtils.getStructuredSelection(selection);
Repository repository = SelectionUtils.getRepository(structuredSelection);
if (repository == null) {
return null;
}
return new GitFlowRepository(repository);
}
Aggregations