clone.setURI(resolvedUri); if (monitor != null) clone.setProgressMonitor(monitor); Repository subRepo = null; try (Git git = clone.call()) {
generator.getPath())); if (monitor != null) { clone.setProgressMonitor(monitor);
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); } }
/** * In lieu of sparse checkout since it's not yet supported in JGit: * https://bugs.eclipse.org/bugs/show_bug.cgi?id=383772 */ public void cloneNoCheckout(boolean withProgress) throws Exception { CloneCommand clone = Git.cloneRepository().setURI(repositoryUrl).setDirectory(localRepo.getDirectory().getParentFile()).setNoCheckout(true); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=442029 if (credentialsProvider != null) clone.setCredentialsProvider(credentialsProvider); if (withProgress) clone.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out))); clone.call(); }
/** * Function to clone the repository * * @throws IOException if something goes wrong, this exception is thrown */ public void cloneRepository() throws IOException { try { Git.cloneRepository() .setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out))) .setURI(url) .setDirectory(directory) .setBranchesToClone(singleton(branch)) .setBranch(branch) .call(); } catch (GitAPIException ex) { //Because the GitAPIException is abstract and cannot be instantiated, another (similar) exception is used throw new IOException("[+]There was an error cloing " + name + ". Verify your internet connection and the permissions of the folder!"); } }
private Git cloneRepository(final File workingDir) throws GitAPIException { final CloneCommand cloneCommand = Git.cloneRepository() .setURI(gitUrl) .setDirectory(workingDir) .setProgressMonitor(PROGRESS_MONITOR) .setCredentialsProvider(user) .setTimeout(cloneTimeoutSeconds); if (StringUtils.isNotEmpty(branchName)) { final String refBranchName = "refs/heads/" + branchName; cloneCommand.setBranchesToClone(ImmutableSet.of(refBranchName)) .setBranch(refBranchName); // prevent clone command from looking at the HEAD of the master branch } return cloneCommand.call(); }
private Git cloneRepository(final File workingDir) throws GitAPIException { return Git.cloneRepository() .setURI(gitUrl) .setDirectory(workingDir) .setProgressMonitor(PROGRESS_MONITOR) .setCredentialsProvider(user) .setTimeout(cloneTimeoutSeconds) .call(); }
.format(starterConfiguration.getGithubRepository(), organization, githubConfig.getRepository())) .setDirectory(workDir) .setProgressMonitor(NullProgressMonitor.INSTANCE) .setCredentialsProvider(credentialsProvider) .call()) {
File client = new File(clientPath); client.mkdirs(); try (Git result = Git.cloneRepository().setProgressMonitor(new ProgressMonitor() { private int totalCount = 0; private int progress = 0;
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; }
@Override @Nonnull protected VcsFullReference downloadToInternal(@Nonnull Path targetDirectory, @Nullable ProgressMonitor progressMonitor) throws VcsException { Ref ref = null; final GitVcsUri uri = gitVcsUriFor(getReference()); final Git git; try { ref = resolveRemoteRef(); if (ref == null) { throw new VcsValidationException("Could not find ref " + uri + "@" + getReference().getRef() + "."); } final String refName = ref.getName(); LOGGER.debug("Clone remote refs from {}@{} to {}...", uri, refName, targetDirectory); git = Git.cloneRepository() .setProgressMonitor(toGitProgressMonitor(progressMonitor)) .setURI(uri.getUri().toString()) .setDirectory(targetDirectory.toFile()) .setBranch(refName) .call(); LOGGER.debug("Clone remote refs from {}@{} to {}... DONE!", uri, refName, targetDirectory); } catch (final GitAPIException e) { throw new VcsException("Cannot clone " + uri + "@" + (ref != null ? ref.getName() : "unresolved") + " to " + targetDirectory + ".", e); } final String fullRevision = fullRevisionOf(git); removeGitDirectoryIfNeeded(targetDirectory, git); return new VcsFullReference(getReference(), fullRevision); }
clone.setURI(resolvedUri); if (monitor != null) clone.setProgressMonitor(monitor); Repository subRepo = clone.call().getRepository();
@Override protected Git getGitRepo() throws Exception { if (stagingDirectory.exists() && new File(stagingDirectory, "HEAD").exists()) { Git git = Git.open(stagingDirectory); git.fetch().setRemote(getRemoteUrl(null, null)).setProgressMonitor(new TextProgressMonitor()).setRefSpecs(new RefSpec("refs/heads/master")).call(); } else { Git.cloneRepository() .setURI(getRemoteUrl(null, null)) .setProgressMonitor(new TextProgressMonitor()) .setDirectory(stagingDirectory) .setNoCheckout(true) .setBare(true) .call(); } Repository r = null; RepositoryBuilder b = new RepositoryBuilder().setGitDir(stagingDirectory).setWorkTree(sourceDirectory); r = b.build(); final Git git = Git.wrap(r); return git; }
clone.setURI(resolvedUri); if (monitor != null) clone.setProgressMonitor(monitor); Repository subRepo = null; try (Git git = clone.call()) {
generator.getPath())); if (monitor != null) { clone.setProgressMonitor(monitor);
Constants.MODULES), generator.getPath())); if (monitor != null) clone.setProgressMonitor(monitor); submoduleRepo = clone.call().getRepository();
@Override public Result execute(UIExecutionContext context) throws Exception { DirectoryResource cloneFolder = targetDirectory.getValue(); if (!cloneFolder.exists()) { cloneFolder.mkdirs(); } Git clone = null; try { CloneCommand cloneCommand = Git.cloneRepository().setURI(uri.getValue()) .setDirectory(cloneFolder.getUnderlyingResourceObject()); cloneCommand.setProgressMonitor(new ProgressMonitorAdapter(context.getProgressMonitor())); clone = cloneCommand.call(); } finally { getGitUtils().close(clone); } context.getUIContext().setSelection(cloneFolder); return Results.success(); }
CloneCommand cloneCommand = Git.cloneRepository() .setURI(mRepo.getRemoteURL()).setCloneAllBranches(true) .setProgressMonitor(new RepoCloneMonitor()) .setTransportConfigCallback(new SgitTransportCallback()) .setDirectory(localRepo)
CloneCommand command = Git.cloneRepository().setURI( repository.getFetchUrl() ); command.setCredentialsProvider( credentials ).setBranch( branch ).setDirectory( fileSet.getBasedir() ); command.setProgressMonitor( monitor ); git = command.call();
CloneCommand cloneCommand = Git.cloneRepository() .setURI(mRepo.getRemoteURL()).setCloneAllBranches(true) .setProgressMonitor(new RepoCloneMonitor()) .setTransportConfigCallback(new SgitTransportCallback()) .setDirectory(localRepo)