public static void cloneRepo(File projectFolder, String cloneUrl, CredentialsProvider credentialsProvider, final File sshPrivateKey, final File sshPublicKey, String remote) { // clone the repo! boolean cloneAll = false; LOG.info("Cloning git repo " + cloneUrl + " into directory " + projectFolder.getAbsolutePath()); CloneCommand command = Git.cloneRepository(); GitHelpers.configureCommand(command, credentialsProvider, sshPrivateKey, sshPublicKey); command = command.setCredentialsProvider(credentialsProvider). setCloneAllBranches(cloneAll).setURI(cloneUrl).setDirectory(projectFolder).setRemote(remote); try { command.call(); } catch (Throwable e) { LOG.error("Failed to command remote repo " + cloneUrl + " due: " + e.getMessage(), e); throw new RuntimeException("Failed to command remote repo " + cloneUrl + " due: " + e.getMessage()); } }
@Override public CloneCommand configure(CloneCommand cmd) { return addAuthentication(cmd).setRemote(remote.getShortRef()).setGitDir(repository.getDirectory()); }
public static void cloneRepo(File projectFolder, String cloneUrl, CredentialsProvider credentialsProvider, final File sshPrivateKey, final File sshPublicKey, String remote, String tag) { StopWatch watch = new StopWatch(); // clone the repo! boolean cloneAll = true; LOG.info("Cloning git repo " + cloneUrl + " into directory " + projectFolder.getAbsolutePath() + " cloneAllBranches: " + cloneAll); CloneCommand command = Git.cloneRepository(); GitUtils.configureCommand(command, credentialsProvider, sshPrivateKey, sshPublicKey); command = command.setCredentialsProvider(credentialsProvider). setCloneAllBranches(cloneAll).setURI(cloneUrl).setDirectory(projectFolder).setRemote(remote); try { Git git = command.call(); if (tag != null){ git.checkout().setName(tag).call(); } } catch (Throwable e) { LOG.error("Failed to command remote repo " + cloneUrl + " due: " + e.getMessage(), e); throw new RuntimeException("Failed to command remote repo " + cloneUrl + " due: " + e.getMessage()); } finally { LOG.info("cloneRepo took " + watch.taken()); } }
private Git connect(File bareRoot, File root) throws MalformedURLException, GitAPIException { return Git.cloneRepository() .setURI(bareRoot.getAbsolutePath()) .setRemote(remote) .setDirectory(root).call(); }
private Git connect(File bareRoot, File root) throws MalformedURLException, GitAPIException { return Git.cloneRepository() .setURI(bareRoot.getAbsolutePath()) .setRemote(remote) .setDirectory(root).call(); }
public static boolean cloneRepo(final String uri, final File cloneTo, final String branch, final GitCloneProgressCallback callback) { Git result = null; try { final CloneCommand clone = Git.cloneRepository() .setURI(uri).setDirectory(cloneTo) .setBare(false).setRemote(REMOTE_NAME).setNoCheckout(false) .setCloneAllBranches(false).setCloneSubmodules(false) .setProgressMonitor(callback); if (!branch.isEmpty()) { if (branch.contains("/")) { clone.setBranch(branch.substring(branch.lastIndexOf('/') + 1)); } else { clone.setBranch(branch); } } result = clone.call(); return true; } catch (GitAPIException e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } return false; }
LOG.info("Cloning remote repo " + repo); CloneCommand command = Git.cloneRepository().setCredentialsProvider(credentials). setURI(repo).setDirectory(localRepo).setRemote(remoteName); git = command.call(); } else {
private Git connect(File root) throws MalformedURLException, GitAPIException { return Git.cloneRepository() .setURI(REPO) .setRemote(remote) .setDirectory(root).call(); } }
private Git connect(File root) throws MalformedURLException, GitAPIException { return Git.cloneRepository() .setURI(REPO) .setRemote(remote) .setDirectory(root).call(); } }
LOG.info("Cloning git repo " + repo + " into directory " + confDir.getCanonicalPath() + " cloneAllBranches: " + cloneAll); CloneCommand command = Git.cloneRepository().setCredentialsProvider(getCredentials()). setCloneAllBranches(cloneAll).setURI(repo).setDirectory(confDir).setRemote(remote); try { git = command.call();
.setURI( cloneUrl ) .setDirectory( rootDir ) .setRemote( "origin" ) .call();
public static void cloneRepo(String uri, File cloneTo) { Git result = null; try { result = Git.cloneRepository().setURI(uri).setDirectory(cloneTo) .setBranch(MASTER_BRANCH).setBare(false).setRemote(REMOTE_NAME) .setNoCheckout(false).setCloneAllBranches(false).setCloneSubmodules(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } }
public static void cloneRepo(String uri, File cloneTo, String branch) { Git result = null; try { result = Git.cloneRepository().setURI(uri).setDirectory(cloneTo) .setBranch(branch).setBare(false).setRemote(REMOTE_NAME) .setNoCheckout(false).setCloneAllBranches(false).setCloneSubmodules(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } }
if (!gitDir.exists()) { if (remote) { new CloneCommand().setCredentialsProvider(provider).setRemote("origin").setBranch("master").setURI(gitUrl).setDirectory(baseDir).call(); git.branchCreate().setName(branchName).call(); git.checkout().setName(branchName).call();
CloneCommand cloneCommand = Git.cloneRepository() .setURI(gitUrl) .setRemote("upstream") .setDirectory(installDir);
public static void cloneRepo(String uri, File cloneTo, String branch, GitUser user) { Git result = null; try { result = Git.cloneRepository().setURI(uri).setDirectory(cloneTo) .setBranch(branch).setBare(false).setRemote(REMOTE_NAME) .setNoCheckout(false).setCloneAllBranches(false).setCloneSubmodules(false) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.getUsername(), user.getPassword())).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } }
.setURI(url) .setBranch(branch) .setRemote(remote) .setDirectory(path) .setCredentialsProvider(credentialProvider)
.setURI(url) .setBranch(branch) .setRemote(remote) .setDirectory(path) .setCredentialsProvider(credentialProvider)