use of org.eclipse.egit.gitflow.WrongGitFlowStateException in project egit by eclipse.
the class ReleaseStartHandler method getStartCommit.
private String getStartCommit(ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
IStructuredSelection selection = SelectionUtils.getStructuredSelection(currentSelection);
if (selection.getFirstElement() instanceof PlotCommit) {
RevCommit plotCommit = (RevCommit) selection.getFirstElement();
return plotCommit.getName();
} else {
GitFlowRepository gitFlowRepository = GitFlowHandlerUtil.getRepository(event);
if (gitFlowRepository == null) {
throw new ExecutionException(UIText.ReleaseStartHandler_startCommitCouldNotBeDetermined);
}
RevCommit head;
try {
head = gitFlowRepository.findHead();
} catch (WrongGitFlowStateException e) {
throw new ExecutionException(e.getMessage(), e);
}
return head.getName();
}
}
use of org.eclipse.egit.gitflow.WrongGitFlowStateException in project egit by eclipse.
the class InitDialog method okPressed.
@Override
protected void okPressed() {
String master = gitflowInitConfig.getMaster();
Repository repository = gfRepo.getRepository();
if (isMasterBranchAvailable(master, repository)) {
super.okPressed();
return;
}
boolean createBranch = openQuestion(getShell(), InitDialog_masterBranchIsMissing, NLS.bind(InitDialog_selectedMasterBranchDoesNotExistCreateNow, master));
if (!createBranch) {
return;
}
try {
RevCommit head = gfRepo.findHead();
new CreateLocalBranchOperation(repository, master, head).execute(null);
} catch (CoreException | WrongGitFlowStateException e) {
throw new RuntimeException(e);
}
super.okPressed();
}
use of org.eclipse.egit.gitflow.WrongGitFlowStateException in project egit by eclipse.
the class InitOperation method execute.
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
try {
setPrefixes(feature, release, hotfix, versionTag);
setBranches(develop, master);
repository.getRepository().getConfig().save();
} catch (IOException e) {
throw new CoreException(error(e.getMessage(), e));
}
SubMonitor progress = SubMonitor.convert(monitor, 3);
if (!repository.hasBranches()) {
new CommitOperation(repository.getRepository(), repository.getConfig().getUser(), repository.getConfig().getUser(), CoreText.InitOperation_initialCommit).execute(progress.newChild(1));
}
try {
if (!isMasterBranchAvailable()) {
throw new CoreException(error(NLS.bind(CoreText.InitOperation_localMasterDoesNotExist, master)));
}
RevCommit head = repository.findHead();
if (!repository.hasBranch(develop)) {
CreateLocalBranchOperation branchFromHead = createBranchFromHead(develop, head);
branchFromHead.execute(progress.newChild(1));
BranchOperation checkoutOperation = new BranchOperation(repository.getRepository(), develop);
checkoutOperation.execute(progress.newChild(1));
}
} catch (WrongGitFlowStateException e) {
throw new CoreException(error(e));
} catch (GitAPIException e) {
throw new CoreException(error(e.getMessage(), e));
}
}
use of org.eclipse.egit.gitflow.WrongGitFlowStateException in project egit by eclipse.
the class ReleaseFinishHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
if (gfRepo == null) {
return error(UIText.Handlers_noGitflowRepositoryFound);
}
final ReleaseFinishOperation releaseFinishOperation;
try {
releaseFinishOperation = new ReleaseFinishOperation(gfRepo);
String releaseBranch = gfRepo.getRepository().getBranch();
String develop = gfRepo.getConfig().getDevelop();
JobUtil.scheduleUserWorkspaceJob(releaseFinishOperation, UIText.ReleaseFinishHandler_finishingRelease, JobFamilies.GITFLOW_FAMILY);
IJobManager jobMan = Job.getJobManager();
jobMan.join(JobFamilies.GITFLOW_FAMILY, null);
MergeResult mergeResult = releaseFinishOperation.getMergeResult();
MergeStatus mergeStatus = mergeResult.getMergeStatus();
if (!MergeStatus.CONFLICTING.equals(mergeStatus)) {
return null;
}
if (handleConflictsOnMaster(gfRepo)) {
return null;
}
MultiStatus status = createMergeConflictInfo(develop, releaseBranch, mergeResult);
ErrorDialog.openError(null, UIText.ReleaseFinishHandler_Conflicts, null, status);
} catch (WrongGitFlowStateException | CoreException | IOException | OperationCanceledException | InterruptedException e) {
return error(e.getMessage(), e);
}
return null;
}
Aggregations