command.setCredentialsProvider(credentialsProvider); command.setCredentialsProvider(new UsernamePasswordCredentialsProvider( credentials.valueOfIndex("username").toString(), credentials.valueOfIndex("password").toString()
.setCredentialsProvider(getCredentialsProvider()) .setTransportConfigCallback(buildTransportConfigCallback()) .call();
public static void fetchRepository(final Git git, final CredentialsProvider credentialsProvider, final RefSpec... refSpecs) { final List<RefSpec> specs = new ArrayList<RefSpec>(); if (refSpecs == null || refSpecs.length == 0) { specs.add(new RefSpec("+refs/heads/*:refs/remotes/origin/*")); specs.add(new RefSpec("+refs/tags/*:refs/tags/*")); specs.add(new RefSpec("+refs/notes/*:refs/notes/*")); } else { specs.addAll(Arrays.asList(refSpecs)); } try { git.fetch() .setCredentialsProvider(credentialsProvider) .setRefSpecs(specs) .call(); } catch (final Exception ex) { throw new RuntimeException(ex); } }
public static void fetchRepository( final Git git, final CredentialsProvider credentialsProvider, final RefSpec... refSpecs ) throws InvalidRemoteException { final List<RefSpec> specs = new ArrayList<RefSpec>(); if ( refSpecs == null || refSpecs.length == 0 ) { specs.add( new RefSpec( "+refs/heads/*:refs/remotes/origin/*" ) ); specs.add( new RefSpec( "+refs/tags/*:refs/tags/*" ) ); specs.add( new RefSpec( "+refs/notes/*:refs/notes/*" ) ); } else { specs.addAll( Arrays.asList( refSpecs ) ); } try { git.fetch() .setCredentialsProvider( credentialsProvider ) .setRefSpecs( specs ) .call(); } catch ( final InvalidRemoteException e ) { throw e; } catch ( final Exception ex ) { throw new RuntimeException( ex ); } }
public void fetch() throws Exception { FetchCommand fetchCommand = git.fetch(); if (credentialsProvider != null) fetchCommand.setCredentialsProvider(credentialsProvider); try { fetchCommand.call(); } catch (JGitInternalException | TransportException ex) { // LocalRepo object might be out of sync with actual local repo, so recreate objects for next time reconnect(); throw ex; } }
public synchronized void fetch() throws IOException { long t0 = System.currentTimeMillis(); GitRepository gitRepository = getGitRepository(); try { ensureLocalClone(); FetchCommand fc = git.fetch(); if ((!Strings.isNullOrEmpty(gitRepository.getUsername())) || (!Strings.isNullOrEmpty(gitRepository.getPassword()))) { fc = fc.setCredentialsProvider(new UsernamePasswordCredentialsProvider( Strings.nullToEmpty(gitRepository.getUsername()), Strings.nullToEmpty(gitRepository.getPassword()))); } fc.call(); } catch (GitAPIException e) { throw new IOException(e); } finally { long t1 = System.currentTimeMillis(); logger.info("fetch took {} ms", t1 - t0); } }
@Override public String fetch(String localBranchName, String remoteBranchName) { RefSpec spec = new RefSpec().setSourceDestination(localBranchName, remoteBranchName); FetchCommand command = _git.fetch(); command.setRefSpecs(spec); FetchResult result = null; try { if(_cp != null) command.setCredentialsProvider(_cp); result = command.call(); } catch (Throwable e) { throw new RuntimeException(String.format( "Failed to fetch from [%s] to [%s]", remoteBranchName, localBranchName), e); } return result.getMessages(); }
git.fetch() .setProgressMonitor(PROGRESS_MONITOR) .setCredentialsProvider(user) .setTimeout(pullPushTimeoutSeconds) .call();
git.fetch() .setProgressMonitor(PROGRESS_MONITOR) .setCredentialsProvider(user) .setTimeout(pullPushTimeoutSeconds) .call();
public void execute() throws InvalidRemoteException { try { final List<RefSpec> specs = git.updateRemoteConfig(remote, refSpecs); git._fetch() .setCredentialsProvider(credentialsProvider) .setRemote(remote.getK1()) .setRefSpecs(specs) .call(); } catch (final InvalidRemoteException e) { throw e; } catch (final Exception ex) { throw new RuntimeException(ex); } } }
.setProgressMonitor(new JGitProgressMonitor(listener)) .setRemote(url) .setCredentialsProvider(getProvider()) .setTagOpt(tags ? TagOpt.FETCH_TAGS : TagOpt.NO_TAGS) .setRefSpecs(refspecs);
/** {@inheritDoc} */ @Override public void fetch(String remoteName, RefSpec... refspec) throws GitException { try (Repository repo = getRepository()) { FetchCommand fetch = git(repo).fetch().setTagOpt(TagOpt.FETCH_TAGS); if (remoteName != null) fetch.setRemote(remoteName); fetch.setCredentialsProvider(getProvider()); List<RefSpec> refSpecs = new ArrayList<>(); if (refspec != null && refspec.length > 0) for (RefSpec rs: refspec) if (rs != null) refSpecs.add(rs); fetch.setRefSpecs(refSpecs); fetch.call(); } catch (GitAPIException e) { throw new GitException(e); } }
@Override public void execute() throws GitException, InterruptedException { try (Repository repo = getRepository()) { Git git = git(repo); List<RefSpec> allRefSpecs = new ArrayList<>(); if (refspecs != null) for (RefSpec rs: refspecs) if (rs != null) allRefSpecs.add(rs); FetchCommand fetch = git.fetch(); fetch.setTagOpt(tags ? TagOpt.FETCH_TAGS : TagOpt.NO_TAGS); /* JGit 4.5 required a work around that the tags refspec had to be passed in addition to setting * the FETCH_TAGS tagOpt. JGit 4.9.0 fixed that bug. * However, JGit 4.9 and later will not accept an empty refspec. * If the refspec is empty and tag fetch is requested, must add the tags refspec to fetch. */ if (allRefSpecs.isEmpty() && tags) { allRefSpecs.add(new RefSpec("+refs/tags/*:refs/tags/*")); } fetch.setRemote(url.toString()); fetch.setCredentialsProvider(getProvider()); fetch.setRefSpecs(allRefSpecs); fetch.setRemoveDeletedRefs(shouldPrune); fetch.call(); } catch (GitAPIException e) { throw new GitException(e); } } };
.setCredentialsProvider( credentialsProvider ) .setRefSpecs( specs ) .setRemote( origin )
try { GitHelpers.checkoutBranch(git, branch); FetchResult fetchResult = git.fetch().setTimeout(gitTimeout).setCredentialsProvider(credentialsProvider).setRemote(remoteRef).setRefSpecs(new RefSpec("refs/heads/" + branch)).call(); Ref fetchRef = fetchResult.getAdvertisedRef("refs/heads/" + branch); git.branchRename().setOldName(branch).setNewName(branch + "-tmp").call();
FetchCommand fetchCommand = git.fetch(); if (StringUtils.isNotBlank(login)) { fetchCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(login, password));
try { GitHelpers.checkoutBranch(git, branch); FetchResult fetchResult = git.fetch().setTimeout(gitTimeout).setCredentialsProvider(credentialsProvider).setRemote(remoteRef).setRefSpecs(new RefSpec("refs/heads/" + branch)).call(); Ref fetchRef = fetchResult.getAdvertisedRef("refs/heads/" + branch); git.branchRename().setOldName(branch).setNewName(branch + "-tmp").call();
UsernamePasswordCredentialsProvider auth = new UsernamePasswordCredentialsProvider( username, password); fetchCommand.setCredentialsProvider(auth);
git.fetch().setCredentialsProvider( credentials ).setProgressMonitor( monitor ).call();
.setCredentialsProvider(getCredentialsProvider()) .setTransportConfigCallback(buildTransportConfigCallback()) .call();