private void trackBranch(Git git, CheckoutCommand checkout, String label) { checkout.setCreateBranch(true).setName(label) .setUpstreamMode(SetupUpstreamMode.TRACK) .setStartPoint("origin/" + label); }
command.setStartPoint(startPoint.toString());
private void trackBranch(CheckoutCommand checkout, String label) { checkout.setCreateBranch(true).setName(label) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .setStartPoint("origin/" + label); }
/** * Checks out a single file from a commit in the repository and adds it to the working dir. * * @param path - Full path to the file. * @param ref - String representing a commit in the repository. * @throws GitAPIException - failed. */ public void checkout(final String path, final String ref) throws GitAPIException { git.checkout() .setStartPoint(ref) .addPath(path) .call(); }
private void trackBranch(Git git, CheckoutCommand checkout, String branch) { checkout.setCreateBranch(true).setName(branch).setUpstreamMode(TRACK).setStartPoint("origin/" + branch); }
private Git checkoutOrCreateBranch(final Git git) { try { 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(); } } catch (Exception e) { log.error(e.getMessage(),e); } return git; }
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()); } } }
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(); }
private void replaceWith(String[] files, boolean headRevision) { if (files == null || files.length == 0) return; CheckoutCommand checkoutCommand = new Git(currentRepository).checkout(); if (headRevision) checkoutCommand.setStartPoint(Constants.HEAD); for (String path : files) checkoutCommand.addPath(path); try { checkoutCommand.call(); } catch (Exception e) { Activator.handleError(UIText.StagingView_checkoutFailed, e, true); } }
/** * Creates a branch with the passed name and commit id from wich to start the branch. * * @param branchName - The name of the new branch to create. * @param startPoint - The commit from which to start the branch. * @throws GitAPIException - failed. */ public void createBranch(final String branchName, final String startPoint) throws GitAPIException { git.checkout() .setCreateBranch(true) .setName(branchName) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .setStartPoint(startPoint) .call(); }
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; }
/** * Does not do anything if already on target branch. */ public void checkout(String branch) throws Exception { if (!branch.equals(getBranch())) { createBranchIfNeeded(branch); git.checkout().setName(branch).setStartPoint("origin/" + branch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK).call(); // for some reason jgit needs this when branch is switched git.checkout().setName(branch).call(); } }
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); } }
/** * Fetch the version of a config after a particular commit in its history * * @param jobId The job id to check * @param commitId The commit id to fetch * @return The contents of the file after the specified time * @throws GitAPIException If there is a problem retrieving the file after the specified commit * @throws IOException If there is a problem writing to the file */ public String fetchJobConfigFromHistory(String jobId, String commitId) throws GitAPIException, IOException { synchronized (gitDir) { File file = getFileForJobId(jobId); git.checkout().addPath(getPathForJobId(jobId)).setStartPoint(commitId).setName("master").call(); String rv = new String(LessFiles.read(file)); git.reset().setMode(ResetCommand.ResetType.HARD).call(); return rv; } }
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(); }
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(); } }
@Override public void switchToVersion(String version) throws Exception { try (Git git = new Git(repository)) { if (version == null) { version = REMOTE_BRANCH; // TODO fetch git.fetch().setRemote(REMOTE).call(); } Log.logDebug(LOGGER, "GIT switchToVersion {0} ", version); git.reset().setMode(ResetType.HARD).call(); git.checkout().setName(version).call(); git.branchDelete().setForce(true).setBranchNames(LOCAL_BRANCH).call(); git.checkout().setCreateBranch(true).setName(LOCAL_BRANCH).setStartPoint(version).call(); } catch (TransportException e) { throw new NetworkException(e); } }