Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.Transport


  private Map<String, Ref> execute() throws GitAPIException,
      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;
    } 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


    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

  public FetchResult call() throws GitAPIException, InvalidRemoteException,
      org.eclipse.jgit.api.errors.TransportException {
    checkCallable();

    try {
      Transport transport = Transport.open(repo, remote);
      try {
        transport.setCheckFetchedObjects(checkFetchedObjects);
        transport.setRemoveDeletedRefs(isRemoveDeletedRefs());
        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

  @Test
  public void testRepositoryNotFound_Dumb() throws Exception {
    URIish uri = toURIish("/dumb.none/not-found");
    Repository dst = createBareRepository();
    Transport t = Transport.open(dst, uri);
    try {
      try {
        t.openFetch();
        fail("connection opened to not found repository");
      } catch (NoRemoteRepositoryException err) {
        String exp = uri + ": " + uri
            + "/info/refs?service=git-upload-pack not found";
        assertEquals(exp, err.getMessage());
      }
    } finally {
      t.close();
    }
  }
View Full Code Here

  @Test
  public void testRepositoryNotFound_Smart() throws Exception {
    URIish uri = toURIish("/smart.none/not-found");
    Repository dst = createBareRepository();
    Transport t = Transport.open(dst, uri);
    try {
      try {
        t.openFetch();
        fail("connection opened to not found repository");
      } catch (NoRemoteRepositoryException err) {
        String exp = uri + ": " + uri
            + "/info/refs?service=git-upload-pack not found";
        assertEquals(exp, err.getMessage());
      }
    } finally {
      t.close();
    }
  }
View Full Code Here

    u.setNewObjectId(Q);
    assertEquals(RefUpdate.Result.FORCED, u.forceUpdate());

    Repository dst = createBareRepository();
    Ref head;
    Transport t = Transport.open(dst, dumbAuthNoneURI);
    try {
      FetchConnection c = t.openFetch();
      try {
        head = c.getRef(Constants.HEAD);
      } finally {
        c.close();
      }
    } finally {
      t.close();
    }
    assertNotNull("has " + Constants.HEAD, head);
    assertEquals(Q, head.getObjectId());
  }
View Full Code Here

    assertTrue("HEAD used to be present", headref.delete());
    assertFalse("HEAD is gone", headref.exists());

    Repository dst = createBareRepository();
    Ref head;
    Transport t = Transport.open(dst, dumbAuthNoneURI);
    try {
      FetchConnection c = t.openFetch();
      try {
        head = c.getRef(Constants.HEAD);
      } finally {
        c.close();
      }
    } finally {
      t.close();
    }
    assertNull("has no " + Constants.HEAD, head);
  }
View Full Code Here

    u.setNewObjectId(Q);
    assertEquals(RefUpdate.Result.FORCED, u.forceUpdate());

    Repository dst = createBareRepository();
    Ref head;
    Transport t = Transport.open(dst, smartAuthNoneURI);
    try {
      FetchConnection c = t.openFetch();
      try {
        head = c.getRef(Constants.HEAD);
      } finally {
        c.close();
      }
    } finally {
      t.close();
    }
    assertNotNull("has " + Constants.HEAD, head);
    assertEquals(Q, head.getObjectId());
  }
View Full Code Here

  @Test
  public void testListRemote_Smart_WithQueryParameters() throws Exception {
    URIish myURI = toURIish("/snone/do?r=1&p=test.git");
    Repository dst = createBareRepository();
    Transport t = Transport.open(dst, myURI);
    try {
      try {
        t.openFetch();
        fail("test did not fail to find repository as expected");
      } catch (NoRemoteRepositoryException err) {
        // expected
      }
    } finally {
      t.close();
    }

    List<AccessEvent> requests = getRequests();
    assertEquals(1, requests.size());
View Full Code Here

  }

  @Test
  public void testListRemote_Dumb_NeedsAuth() throws Exception {
    Repository dst = createBareRepository();
    Transport t = Transport.open(dst, dumbAuthBasicURI);
    try {
      try {
        t.openFetch();
        fail("connection opened even info/refs needs auth basic");
      } catch (TransportException err) {
        String exp = dumbAuthBasicURI + ": "
            + JGitText.get().notAuthorized;
        assertEquals(exp, err.getMessage());
      }
    } finally {
      t.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.