use of org.eclipse.egit.gitflow.WrongGitFlowStateException 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.WrongGitFlowStateException in project egit by eclipse.
the class HotfixFinishHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
if (gfRepo == null) {
return error(UIText.Handlers_noGitflowRepositoryFound);
}
HotfixFinishOperation hotfixFinishOperation;
try {
hotfixFinishOperation = new HotfixFinishOperation(gfRepo);
String hotfixBranch = gfRepo.getRepository().getBranch();
String develop = gfRepo.getConfig().getDevelop();
JobUtil.scheduleUserWorkspaceJob(hotfixFinishOperation, UIText.HotfixFinishHandler_finishingHotfix, JobFamilies.GITFLOW_FAMILY);
IJobManager jobMan = Job.getJobManager();
jobMan.join(JobFamilies.GITFLOW_FAMILY, null);
MergeResult mergeResult = hotfixFinishOperation.getMergeResult();
MergeStatus mergeStatus = mergeResult.getMergeStatus();
if (!MergeStatus.CONFLICTING.equals(mergeStatus)) {
return null;
}
if (handleConflictsOnMaster(gfRepo)) {
return null;
}
MultiStatus status = createMergeConflictInfo(develop, hotfixBranch, mergeResult);
ErrorDialog.openError(null, UIText.HotfixFinishHandler_Conflicts, null, status);
} catch (WrongGitFlowStateException | CoreException | IOException | OperationCanceledException | InterruptedException e) {
return error(e.getMessage(), e);
}
return null;
}
use of org.eclipse.egit.gitflow.WrongGitFlowStateException in project egit by eclipse.
the class AbstractVersionFinishOperation method safeCreateTag.
/**
* Check if tag exists before trying to create it.
*
* @param monitor
* @param tagName
* @param tagMessage
* @throws CoreException
*/
protected void safeCreateTag(IProgressMonitor monitor, String tagName, String tagMessage) throws CoreException {
RevCommit head;
try {
head = repository.findHead();
} catch (WrongGitFlowStateException e) {
throw new CoreException(error(e));
}
RevCommit commitForTag;
try {
commitForTag = repository.findCommitForTag(versionName);
if (commitForTag == null) {
createTag(monitor, head, tagName, tagMessage);
} else if (!head.equals(commitForTag)) {
throw new CoreException(error(format(CoreText.AbstractVersionFinishOperation_tagNameExists, versionName)));
}
} catch (IOException e) {
throw new CoreException(error(e));
}
}
use of org.eclipse.egit.gitflow.WrongGitFlowStateException in project egit by eclipse.
the class FeatureRebaseOperation method execute.
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
try {
if (!repository.isFeature()) {
throw new WrongGitFlowStateException(CoreText.FeatureRebaseOperation_notOnAFeatureBranch);
}
Repository jgitRepo = repository.getRepository();
Ref develop = jgitRepo.exactRef(repository.getConfig().getDevelopFull());
RebaseOperation op = new RebaseOperation(jgitRepo, develop);
op.execute(monitor);
operationResult = op.getResult();
} catch (WrongGitFlowStateException | IOException e) {
throw new CoreException(error(e.getMessage(), e));
}
}
use of org.eclipse.egit.gitflow.WrongGitFlowStateException in project egit by eclipse.
the class ReleaseFinishOperationTest method testReleaseFinishFail.
@Test
public void testReleaseFinishFail() throws Exception {
testRepository.createInitialCommit("testReleaseFinishFail\n\nfirst commit\n");
Repository repository = testRepository.getRepository();
new InitOperation(repository).execute(null);
GitFlowRepository gfRepo = new GitFlowRepository(repository);
new ReleaseStartOperation(gfRepo, MY_RELEASE).execute(null);
new BranchOperation(repository, gfRepo.getConfig().getDevelop()).execute(null);
try {
new ReleaseFinishOperation(gfRepo).execute(null);
fail();
} catch (WrongGitFlowStateException e) {
// success
}
}
Aggregations