Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.FetchConnection


    final URL loc = bundle.toURL();
    final URIish uri = new URIish(loc);

    final Transport t = new TransportBundleStream(git.getRepository(), uri, loc.openStream());
    try {
      final FetchConnection src = t.openFetch();
      final Ref target = src.getRef(refName);

      final Collection<Ref> want = singleton(target);
      final Set<ObjectId> have = emptySet();
      src.fetch(NullProgressMonitor.INSTANCE, want, have);

      return target.getObjectId().getName();

    } finally {
      t.close();
View Full Code Here


        if (heads)
          refSpecs.add(new RefSpec(
              "refs/heads/*:refs/remotes/origin/*"));
        Collection<Ref> refs;
        Map<String, Ref> refmap = new HashMap<String, Ref>();
        FetchConnection fc = transport.openFetch();
        try {
          refs = fc.getRefs();
          if (refSpecs.isEmpty())
            for (Ref r : refs)
              refmap.put(r.getName(), r);
          else
            for (Ref r : refs)
              for (RefSpec rs : refSpecs)
                if (rs.matchSource(r)) {
                  refmap.put(r.getName(), r);
                  break;
                }
        } finally {
          fc.close();
        }
        return refmap.values();

      } catch (TransportException e) {
        throw new JGitInternalException(
View Full Code Here

      InvalidRemoteException,
      org.eclipse.jgit.api.errors.TransportException {
    checkCallable();

    Transport transport = null;
    FetchConnection fc = null;
    try {
      transport = Transport.open(repo, remote);
      transport.setOptionUploadPack(uploadPack);
      configure(transport);
      Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
      if (tags)
        refSpecs.add(new RefSpec(
            "refs/tags/*:refs/remotes/origin/tags/*")); //$NON-NLS-1$
      if (heads)
        refSpecs.add(new RefSpec("refs/heads/*:refs/remotes/origin/*")); //$NON-NLS-1$
      Collection<Ref> refs;
      Map<String, Ref> refmap = new HashMap<String, Ref>();
      fc = transport.openFetch();
      refs = fc.getRefs();
      if (refSpecs.isEmpty())
        for (Ref r : refs)
          refmap.put(r.getName(), r);
      else
        for (Ref r : refs)
          for (RefSpec rs : refSpecs)
            if (rs.matchSource(r)) {
              refmap.put(r.getName(), r);
              break;
            }
      return refmap.values();
    } catch (URISyntaxException e) {
      throw new InvalidRemoteException(MessageFormat.format(
          JGitText.get().invalidRemote, remote));
    } catch (NotSupportedException e) {
      throw new JGitInternalException(
          JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
          e);
    } catch (TransportException e) {
      throw new org.eclipse.jgit.api.errors.TransportException(
          e.getMessage(),
          e);
    } finally {
      if (fc != null)
        fc.close();
      if (transport != null)
        transport.close();
    }
  }
View Full Code Here

      InvalidRemoteException,
      org.eclipse.jgit.api.errors.TransportException {
    checkCallable();

    Transport transport = null;
    FetchConnection fc = null;
    try {
      if (repo != null)
        transport = Transport.open(repo, remote);
      else
        transport = Transport.open(new URIish(remote));
      transport.setOptionUploadPack(uploadPack);
      configure(transport);
      Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
      if (tags)
        refSpecs.add(new RefSpec(
            "refs/tags/*:refs/remotes/origin/tags/*")); //$NON-NLS-1$
      if (heads)
        refSpecs.add(new RefSpec("refs/heads/*:refs/remotes/origin/*")); //$NON-NLS-1$
      Collection<Ref> refs;
      Map<String, Ref> refmap = new HashMap<String, Ref>();
      fc = transport.openFetch();
      refs = fc.getRefs();
      if (refSpecs.isEmpty())
        for (Ref r : refs)
          refmap.put(r.getName(), r);
      else
        for (Ref r : refs)
          for (RefSpec rs : refSpecs)
            if (rs.matchSource(r)) {
              refmap.put(r.getName(), r);
              break;
            }
      return refmap.values();
    } catch (URISyntaxException e) {
      throw new InvalidRemoteException(MessageFormat.format(
          JGitText.get().invalidRemote, remote));
    } catch (NotSupportedException e) {
      throw new JGitInternalException(
          JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
          e);
    } catch (TransportException e) {
      throw new org.eclipse.jgit.api.errors.TransportException(
          e.getMessage(),
          e);
    } finally {
      if (fc != null)
        fc.close();
      if (transport != null)
        transport.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.FetchConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.