private void trackBranch(Git git, CheckoutCommand checkout, String label) { checkout.setCreateBranch(true).setName(label) .setUpstreamMode(SetupUpstreamMode.TRACK) .setStartPoint("origin/" + label); }
command.setCreateBranch(settings.valueOfIndex("createBranch").toBoolean()); command.setForce(settings.valueOfIndex("force").toBoolean()); command.setOrphan(settings.valueOfIndex("orphan").toBoolean());
private void trackBranch(CheckoutCommand checkout, String label) { checkout.setCreateBranch(true).setName(label) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .setStartPoint("origin/" + label); }
public void checkoutNewBranch(String name) throws GitAPIException, JGitInternalException, StopTaskException { mRepo.getGit().checkout().setName(name).setCreateBranch(true).call(); }
public void checkoutNewBranch(String name) throws GitAPIException, JGitInternalException, StopTaskException { mRepo.getGit().checkout().setName(name).setCreateBranch(true).call(); }
private void checkoutToBranch(String branch) throws GitAPIException { CheckoutCommand checkoutCommand = clonedRepo.checkout() .setCreateBranch(false) .setName(branch); List<Ref> refList = clonedRepo.branchList().call(); if (!anyRefMatches(refList, branch)) { checkoutCommand = checkoutCommand .setCreateBranch(true) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .setStartPoint("origin/" + branch); } checkoutCommand .call(); }
private void checkoutAllBranches(Repository repository) throws GitAPIException { final Git git = Git.wrap(repository); for (final Ref ref : git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call()) { final String refName = ref.getName(); final String branchName = refName.substring(refName.lastIndexOf('/') + 1); try { git.checkout().setCreateBranch(true).setName(branchName).setStartPoint("origin/" + branchName).call(); } catch (RefAlreadyExistsException e) { LOGGER.warning("Already exists, so ignoring " + e.getMessage()); } } }
protected void doStatus(Exchange exchange, String operation) throws Exception { Status status = null; try { if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) { git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call(); } status = git.status().call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } updateExchange(exchange, status); }
protected void doLog(Exchange exchange, String operation) throws Exception { Iterable<RevCommit> revCommit = null; try { if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) { git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call(); } revCommit = git.log().call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } updateExchange(exchange, revCommit); }
public void checkoutFromLocal(String name, String branch) throws GitAPIException, JGitInternalException, StopTaskException { mRepo.getGit().checkout().setCreateBranch(true).setName(branch) .setStartPoint(name).call(); }
public void checkoutFromLocal(String name, String branch) throws GitAPIException, JGitInternalException, StopTaskException { mRepo.getGit().checkout().setCreateBranch(true).setName(branch) .setStartPoint(name).call(); }
@Override public Ref checkout(final Git git, final String remote, final boolean createBranch, final SetupUpstreamMode mode, final boolean force) throws GitAPIException { CheckoutCommand checkout = git.checkout(); checkout.setCreateBranch(createBranch); checkout.setName(remote); checkout.setForce(force); checkout.setUpstreamMode(mode); return checkout.call(); }
protected void doClean(Exchange exchange, String operation) throws Exception { Set<String> result = null; try { if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) { git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call(); } result = git.clean().setCleanDirectories(true).call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } updateExchange(exchange, result); }
Git checkoutOrCreateBranch(final Git git) throws GitAPIException, IOException { if (!branch.equals(git.getRepository().getBranch())) { CheckoutCommand checkoutCommand = git.checkout() .setCreateBranch(true) .setName(branch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK); if (remoteBranchExists(git)) { checkoutCommand.setStartPoint("origin/" + branch); } checkoutCommand.call(); } return git; }
private static void checkoutRepository(Git repository, String branch) { try { String fullBranchReference = addPrefix(repository, branch); CheckoutCommand checkoutCommand = repository.checkout(); checkoutCommand.setName(fullBranchReference); if (isBranch(repository, branch) && !branchExistsLocally(repository, fullBranchReference)) { checkoutCommand.setCreateBranch(true); } checkoutCommand.call(); } catch (GitAPIException e) { throw GitException.buildErrorOnReference(e, branch); } }
private void doCheckout(String ref, String branch) throws GitException { try (Repository repo = getRepository()) { git(repo).checkout().setName(branch).setCreateBranch(true).setForce(true).setStartPoint(ref).call(); } catch (GitAPIException e) { throw new GitException("Could not checkout " + branch + " with start point " + ref, e); } }
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); } }
public synchronized void checkout(String hash) { try (Git git = openRepository()) { git.reset().setMode(ResetType.HARD).call(); git.checkout().setName(mainBranchName).call(); deleteMMBranch(git); git.checkout().setCreateBranch(true).setName(BRANCH_MM).setStartPoint(hash).setForce(true).setOrphan(true).call(); } catch (Exception e) { throw new RuntimeException(e); } }
public void checkoutFromRemote(String remoteBranchName, String branchName) throws GitAPIException, JGitInternalException, StopTaskException { mRepo.getGit().checkout().setCreateBranch(true).setName(branchName) .setStartPoint(remoteBranchName).call(); mRepo.getGit() .branchCreate() .setUpstreamMode( CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint(remoteBranchName).setName(branchName) .setForce(true).call(); } }
public void checkoutFromRemote(String remoteBranchName, String branchName) throws GitAPIException, JGitInternalException, StopTaskException { mRepo.getGit().checkout().setCreateBranch(true).setName(branchName) .setStartPoint(remoteBranchName).call(); mRepo.getGit() .branchCreate() .setUpstreamMode( CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint(remoteBranchName).setName(branchName) .setForce(true).call(); } }