public static boolean checkoutBranch(Git git, String branch) throws GitAPIException { String current = currentBranch(git); if (equals(current, branch)) { return true; } else if (localBranchExists(git, branch)) { CheckoutCommand checkoutCommand = git.checkout().setName(branch).setForce(true); Ref ref = checkoutCommand.call(); CheckoutResult result = checkoutCommand.getResult(); LOGGER.debug("Checked out branch {} with results: {}", branch, result.getStatus()); return true; } else { LOGGER.debug("Branch {} not found!", branch); return false; } }
public static boolean checkoutBranch(Git git, String branch) throws GitAPIException { String current = currentBranch(git); if (equals(current, branch)) { return true; } else if (localBranchExists(git, branch)) { CheckoutCommand checkoutCommand = git.checkout().setName(branch).setForce(true); Ref ref = checkoutCommand.call(); CheckoutResult result = checkoutCommand.getResult(); LOGGER.debug("Checked out branch {} with results: {}", branch, result.getStatus()); return true; } else { LOGGER.debug("Branch {} not found!", branch); return false; } }
private void createBranch(final String textForBranch, RevCommit commit, IProgressMonitor monitor) throws CoreException, GitAPIException { monitor.setTaskName(UIText.FetchGerritChangePage_CreatingBranchTaskName); CreateLocalBranchOperation bop = new CreateLocalBranchOperation( repository, textForBranch, commit); bop.execute(monitor); CheckoutCommand co = new Git(repository).checkout(); try { co.setName(textForBranch).call(); } catch (CheckoutConflictException e) { final CheckoutResult result = co.getResult(); if (result.getStatus() == Status.CONFLICTS) { final Shell shell = getWizard().getContainer().getShell(); shell.getDisplay().asyncExec(new Runnable() { public void run() { new CheckoutConflictDialog(shell, repository, result .getConflictList()).open(); } }); } } monitor.worked(1); }
private void checkoutToSelectedBranch(final Git git) throws IOException, GitAPIException { boolean createBranch = !ObjectId.isId(branch); if (createBranch) { Ref ref = git.getRepository().exactRef(R_HEADS + branch); if (ref != null) { createBranch = false; } } CheckoutCommand checkout = git.checkout().setCreateBranch(createBranch).setName(branch); checkout.call(); if (checkout.getResult().getStatus() == CheckoutResult.Status.ERROR) { throw ServerLogger.ROOT_LOGGER.failedToPullRepository(null, defaultRemoteRepository); } }
private void checkoutToSelectedBranch(final Git git) throws IOException, GitAPIException { boolean createBranch = !ObjectId.isId(branch); if (createBranch) { Ref ref = git.getRepository().exactRef(R_HEADS + branch); if (ref != null) { createBranch = false; } } CheckoutCommand checkout = git.checkout().setCreateBranch(createBranch).setName(branch); checkout.call(); if (checkout.getResult().getStatus() == CheckoutResult.Status.ERROR) { throw ServerLogger.ROOT_LOGGER.failedToPullRepository(null, defaultRemoteRepository); } }
CheckoutCommand checkout = git.checkout().setName(branch); checkout.call(); if (checkout.getResult().getStatus() == CheckoutResult.Status.ERROR) { throw ServerLogger.ROOT_LOGGER.failedToPullRepository(null, gitConfig.getRepository());
CheckoutCommand checkout = git.checkout().setName(branch); checkout.call(); if (checkout.getResult().getStatus() == CheckoutResult.Status.ERROR) { throw ServerLogger.ROOT_LOGGER.failedToPullRepository(null, gitConfig.getRepository());