use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class DynamicHistoryMenu method getRepository.
private GitFlowRepository getRepository() {
IWorkbenchPart activePart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
Repository repository = Utils.getAdapter(activePart, Repository.class);
if (repository == null) {
return null;
}
return new GitFlowRepository(repository);
}
use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class RepositoryPropertyTester method test.
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (receiver == null) {
return false;
}
Repository repository = null;
if (receiver instanceof String) {
String gitDir = (String) receiver;
repository = org.eclipse.egit.core.Activator.getDefault().getRepositoryCache().getRepository(new File(gitDir));
} else if (receiver instanceof Repository) {
repository = (Repository) receiver;
}
if (repository == null || repository.isBare()) {
return false;
}
GitFlowRepository gitFlowRepository = new GitFlowRepository(repository);
try {
if (IS_INITIALIZED.equals(property)) {
return gitFlowRepository.getConfig().isInitialized();
} else if (IS_FEATURE.equals(property)) {
return gitFlowRepository.isFeature();
} else if (IS_RELEASE.equals(property)) {
return gitFlowRepository.isRelease();
} else if (IS_HOTFIX.equals(property)) {
return gitFlowRepository.isHotfix();
} else if (IS_DEVELOP.equals(property)) {
return gitFlowRepository.isDevelop();
} else if (IS_MASTER.equals(property)) {
return gitFlowRepository.isMaster();
} else if (HAS_DEFAULT_REMOTE.equals(property)) {
return gitFlowRepository.getConfig().hasDefaultRemote();
}
} catch (IOException e) {
Activator.getDefault().getLog().log(error(e.getMessage(), e));
}
return false;
}
use of org.eclipse.egit.gitflow.GitFlowRepository 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;
}
use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class FeatureRebaseHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
FeatureRebaseOperation rebaseOperation = new FeatureRebaseOperation(gfRepo);
JobUtil.scheduleUserWorkspaceJob(rebaseOperation, UIText.FeatureRebaseHandler_rebasingFeature, JobFamilies.GITFLOW_FAMILY);
IJobManager jobMan = Job.getJobManager();
try {
jobMan.join(GITFLOW_FAMILY, null);
} catch (OperationCanceledException | InterruptedException e) {
return error(e.getMessage(), e);
}
RebaseResult operationResult = rebaseOperation.getOperationResult();
RebaseResult.Status status = operationResult.getStatus();
if (status.isSuccessful()) {
return null;
}
if (STOPPED.equals(status)) {
try {
showInteractiveRebaseView(event);
} catch (PartInitException e) {
return error(e.getMessage(), e);
}
}
openWarning(operationResult);
return null;
}
use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.
the class FeatureStartHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
InputDialog inputDialog = new InputDialog(HandlerUtil.getActiveShell(event), UIText.FeatureStartHandler_provideFeatureName, UIText.FeatureStartHandler_pleaseProvideANameForTheNewFeature, // $NON-NLS-1$
"", new FeatureNameValidator(gfRepo));
if (inputDialog.open() != Window.OK) {
return null;
}
final String featureName = inputDialog.getValue();
FeatureStartOperation featureStartOperation = new FeatureStartOperation(gfRepo, featureName);
JobUtil.scheduleUserWorkspaceJob(featureStartOperation, UIText.FeatureStartHandler_startingNewFeature, JobFamilies.GITFLOW_FAMILY);
return null;
}
Aggregations