use of org.eclipse.che.api.git.params.CheckoutParams in project che by eclipse.
the class GitProjectImporter method checkoutBranch.
private void checkoutBranch(GitConnection git, String projectName, String branchName, String startPoint) throws GitException {
final CheckoutParams params = CheckoutParams.create(branchName);
final boolean branchExist = git.branchList(LIST_ALL).stream().anyMatch(branch -> branch.getDisplayName().equals("origin/" + branchName));
final GitCheckoutEvent checkout = newDto(GitCheckoutEvent.class).withWorkspaceId(WorkspaceIdProvider.getWorkspaceId()).withProjectName(projectName);
if (startPoint != null) {
if (branchExist) {
git.checkout(params);
eventService.publish(checkout.withCheckoutOnly(true).withBranchRef(getRemoteBranch(git, branchName)));
} else {
checkoutAndRethrow(git, params.withCreateNew(true).withStartPoint(startPoint).withNoTrack(true), FAILED_CHECKOUT_WITH_START_POINT);
eventService.publish(checkout.withCheckoutOnly(false));
}
} else {
checkoutAndRethrow(git, params, FAILED_CHECKOUT);
eventService.publish(checkout.withCheckoutOnly(true).withBranchRef(getRemoteBranch(git, branchName)));
}
}
Aggregations