use of org.eclipse.egit.core.op.CreateLocalBranchOperation 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.core.op.CreateLocalBranchOperation in project egit by eclipse.
the class FeatureTrackOperation method execute.
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 3);
try {
String newLocalBranch = repository.getConfig().getFeatureBranchName(featureName);
operationResult = fetch(progress.newChild(1), timeout);
if (repository.hasBranch(newLocalBranch)) {
String errorMessage = String.format(CoreText.FeatureTrackOperation_localBranchExists, newLocalBranch);
throw new CoreException(error(errorMessage));
}
CreateLocalBranchOperation createLocalBranchOperation = new CreateLocalBranchOperation(repository.getRepository(), newLocalBranch, remoteFeature, BranchRebaseMode.NONE);
createLocalBranchOperation.execute(progress.newChild(1));
BranchOperation branchOperation = new BranchOperation(repository.getRepository(), newLocalBranch);
branchOperation.execute(progress.newChild(1));
CheckoutResult result = branchOperation.getResult();
if (!Status.OK.equals(result.getStatus())) {
String errorMessage = String.format(CoreText.FeatureTrackOperation_checkoutReturned, newLocalBranch, result.getStatus().name());
throw new CoreException(error(errorMessage));
}
try {
repository.setRemote(newLocalBranch, DEFAULT_REMOTE_NAME);
repository.setUpstreamBranchName(newLocalBranch, repository.getConfig().getFullFeatureBranchName(featureName));
} catch (IOException e) {
throw new CoreException(error(CoreText.FeatureTrackOperation_unableToStoreGitConfig, e));
}
} catch (URISyntaxException e) {
throw new CoreException(error(e.getMessage(), e));
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
throw new CoreException(error(targetException.getMessage(), targetException));
} catch (GitAPIException e) {
throw new CoreException(error(e.getMessage(), e));
}
}
use of org.eclipse.egit.core.op.CreateLocalBranchOperation in project egit by eclipse.
the class GitFlowOperation method start.
/**
* git flow * start
*
* @param monitor
* @param branchName
* @param sourceCommit
* @throws CoreException
*/
protected void start(IProgressMonitor monitor, String branchName, RevCommit sourceCommit) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 2);
CreateLocalBranchOperation branchOperation = createBranchFromHead(branchName, sourceCommit);
branchOperation.execute(progress.newChild(1));
BranchOperation checkoutOperation = new BranchOperation(repository.getRepository(), branchName);
checkoutOperation.execute(progress.newChild(1));
}
use of org.eclipse.egit.core.op.CreateLocalBranchOperation 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));
}
}
Aggregations