Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.Transport


   */
  public Collection<Ref> call() throws GitAPIException,
      JGitInternalException {
    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/*"));
      if (heads)
        refSpecs.add(new RefSpec("refs/heads/*:refs/remotes/origin/*"));
      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(
          JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
          e);
    } finally {
      if (fc != null)
        fc.close();
      if (transport != null)
        transport.close();
    }
  }
View Full Code Here


  public FetchResult call() throws JGitInternalException,
      InvalidRemoteException {
    checkCallable();

    try {
      Transport transport = Transport.open(repo, remote);
      try {
        transport.setCheckFetchedObjects(checkFetchedObjects);
        transport.setRemoveDeletedRefs(removeDeletedRefs);
        transport.setDryRun(dryRun);
        if (tagOption != null)
          transport.setTagOpt(tagOption);
        transport.setFetchThin(thin);
        configure(transport);

        FetchResult result = transport.fetch(monitor, refSpecs);
        return result;
      } finally {
        transport.close();
      }
    } catch (NoRemoteRepositoryException e) {
      throw new InvalidRemoteException(MessageFormat.format(
          JGitText.get().invalidRemote, remote), e);
    } catch (TransportException e) {
View Full Code Here

   }

   private FetchResult runFetch() throws NotSupportedException,
            URISyntaxException, TransportException
   {
      final Transport tn = Transport.open(db, remoteName);
      final FetchResult r;
      try
      {
         tn.setTagOpt(TagOpt.FETCH_TAGS);
         r = tn.fetch(new TextProgressMonitor(), null);
      }
      finally
      {
         tn.close();
      }
      return r;
   }
View Full Code Here

  public Collection<Ref> call() throws Exception {
    checkCallable();

    try {
      Transport transport = Transport.open(repo, remote);
      transport.setOptionUploadPack(uploadPack);

      try {
        Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
        if (tags) {
          refSpecs.add(new RefSpec(
              "refs/tags/*:refs/remotes/origin/tags/*"));
        }
        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();
          for (Ref r : refs) {
            boolean found = refSpecs.isEmpty();
            for (RefSpec rs : refSpecs) {
              if (rs.matchSource(r)) {
                found = true;
                break;
              }
            }
            if (found) {
              refmap.put(r.getName(), r);
            }

          }
        } finally {
          fc.close();
        }
        return refmap.values();

      } catch (TransportException e) {
        throw new JGitInternalException(
            JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
            e);
      } finally {
        transport.close();
      }
    } catch (URISyntaxException e) {
      throw new InvalidRemoteException(MessageFormat.format(
          JGitText.get().invalidRemote, remote));
    } catch (NotSupportedException e) {
View Full Code Here

  public FetchResult call() throws JGitInternalException,
      InvalidRemoteException {
    checkCallable();

    try {
      Transport transport = Transport.open(repo, remote);
      try {
        transport.setCheckFetchedObjects(checkFetchedObjects);
        transport.setRemoveDeletedRefs(removeDeletedRefs);
        transport.setTimeout(timeout);
        transport.setDryRun(dryRun);
        if (tagOption != null)
          transport.setTagOpt(tagOption);
        transport.setFetchThin(thin);
        if (credentialsProvider != null)
          transport.setCredentialsProvider(credentialsProvider);

        FetchResult result = transport.fetch(monitor, refSpecs);
        return result;
      } finally {
        transport.close();
      }
    } catch (NoRemoteRepositoryException e) {
      throw new InvalidRemoteException(MessageFormat.format(
          JGitText.get().invalidRemote, remote), e);
    } catch (TransportException e) {
View Full Code Here

    rc.update(dstcfg);
    dstcfg.save();
  }

  private FetchResult runFetch() throws URISyntaxException, IOException {
    final Transport tn = Transport.open(db, remoteName);
    final FetchResult r;
    try {
      tn.setTagOpt(TagOpt.FETCH_TAGS);
      r = tn.fetch(new TextProgressMonitor(), null);
    } finally {
      tn.close();
    }
    showFetchResult(r);
    return r;
  }
View Full Code Here

  @Argument(index = 0, metaVar = "metaVar_uriish", required = true)
  private String remote;

  @Override
  protected void run() throws Exception {
    final Transport tn = Transport.open(db, remote);
    if (0 <= timeout)
      tn.setTimeout(timeout);
    final FetchConnection c = tn.openFetch();
    try {
      for (final Ref r : c.getRefs()) {
        show(r.getObjectId(), r.getName());
        if (r.getPeeledObjectId() != null)
          show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
      }
    } finally {
      c.close();
      tn.close();
    }
  }
View Full Code Here

  public FetchResult call() throws JGitInternalException,
      InvalidRemoteException {
    checkCallable();

    try {
      Transport transport = Transport.open(repo, remote);
      transport.setCheckFetchedObjects(checkFetchedObjects);
      transport.setRemoveDeletedRefs(removeDeletedRefs);
      transport.setTimeout(timeout);
      transport.setDryRun(dryRun);
      if (tagOption != null)
        transport.setTagOpt(tagOption);
      transport.setFetchThin(thin);
      transport.setCredentialsProvider(credentialsProvider);

      try {
        FetchResult result = transport.fetch(monitor, refSpecs);
        return result;

      } catch (TransportException e) {
        throw new JGitInternalException(
            JGitText.get().exceptionCaughtDuringExecutionOfFetchCommand,
            e);
      } finally {
        transport.close();
      }
    } catch (URISyntaxException e) {
      throw new InvalidRemoteException(MessageFormat.format(
          JGitText.get().invalidRemote, remote));
    } catch (NotSupportedException e) {
View Full Code Here

  /** Inserter to read objects from {@link #local}. */
  private final ObjectReader reader;

  WalkFetchConnection(final WalkTransport t, final WalkRemoteObjectDatabase w) {
    Transport wt = (Transport)t;
        try
        {
            local = (Repository) wt.getClass().getDeclaredField("local").get(wt);
        }
        catch (IllegalAccessException e)
        {
            throw new RuntimeException(e);
        }
        catch (NoSuchFieldException e)
        {
            throw new RuntimeException(e);
        }
        objCheck = wt.isCheckFetchedObjects() ? new ObjectChecker() : null;
    inserter = local.newObjectInserter();
    reader = local.newObjectReader();

    remotes = new ArrayList<WalkRemoteObjectDatabase>();
    remotes.add(w);
View Full Code Here

  @Argument(index = 0, metaVar = "metaVar_uriish", required = true)
  private String remote;

  @Override
  protected void run() throws Exception {
    final Transport tn = Transport.open(db, remote);
    if (0 <= timeout)
      tn.setTimeout(timeout);
    final FetchConnection c = tn.openFetch();
    try {
      for (final Ref r : c.getRefs()) {
        show(r.getObjectId(), r.getName());
        if (r.getPeeledObjectId() != null)
          show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
      }
    } finally {
      c.close();
      tn.close();
    }
  }
View Full Code Here

TOP

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

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.