private void cloneBaseTemplates(Path configTemplatesDir) throws Ap3Exception { try { String prefix = "cloning base templates... "; PrintWriter pw = new PrintWriter(System.out); pw.write(prefix); pw.flush(); SingleLineProgressMonitor pm = new SingleLineProgressMonitor(pw, prefix); CloneCommand cloneCommand = new CloneCommand(); cloneCommand.setDirectory(configTemplatesDir.toFile()); cloneCommand.setURI("https://bitbucket.org/atlassian/ap3-sdk-templates.git"); cloneCommand.setProgressMonitor(pm); cloneCommand.setCloneSubmodules(true); cloneCommand.call(); pm.clear(); pw.write("\r"); pw.write(StringUtils.repeat(' ',prefix.length())); pw.write("\r"); pw.flush(); } catch (GitAPIException e) { throw new Ap3Exception("Unable to retrieve base templates", e); } }
public static GitService cloneRepo(String uri, String dir) throws Exception { if(dir == null || !FileSystemManager.exists(dir)) { log.debug("Cloning \""+uri+"\" to \""+dir+"\""); CloneCommand clone = Git.cloneRepository(); clone.setCloneAllBranches(false); clone.setCloneSubmodules(false); if(dir != null) { clone.setDirectory(new File(dir)); } clone.setURI(uri); try { return new GitService(clone.call()); } catch(Exception e) { if(new File(dir).exists()) { FileUtils.forceDelete(new File(dir)); } throw e; } } return null; }
@Override protected StepStatus businessExecute() { String repoSlug = this.build.getRepository().getSlug(); String repoRemotePath = Utils.getCompleteGithubRepoUrl(repoSlug); String repoLocalPath = this.getInspector().getRepoLocalPath(); try { this.getLogger().debug("Cloning repository " + repoSlug + " in the following directory: " + repoLocalPath); Git.cloneRepository().setCloneSubmodules(true).setURI(repoRemotePath).setDirectory(new File(repoLocalPath)).call(); return StepStatus.buildSuccess(this); } catch (Exception e) { this.addStepError("Repository " + repoSlug + " cannot be cloned.", e); return StepStatus.buildError(this, PipelineState.NOTCLONABLE); } }
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; }
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(); } } }
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(); } } }
.setTransportConfigCallback(new SgitTransportCallback()) .setDirectory(localRepo) .setCloneSubmodules(mCloneRecursive);
.setTransportConfigCallback(new SgitTransportCallback()) .setDirectory(localRepo) .setCloneSubmodules(mCloneRecursive);