Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.FetchResult


      fetch.setDryRun(dryRun);
      fetch.setRemote(remote);
      fetch.setThin(thin);
      fetch.setProgressMonitor(new TextProgressMonitor());

      FetchResult result = fetch.call();
      return result;
   }
View Full Code Here


            ConcurrentRefUpdateException,
            InvalidTagNameException, NoHeadException
   {
      List<Ref> results = new ArrayList<Ref>();
      try {
         FetchResult fetch = repo.fetch().setRemote("origin").call();
         Collection<Ref> refs = fetch.getAdvertisedRefs();
         for (Ref ref : refs) {
            if (ref.getName().startsWith("refs/heads"))
            {
               results.add(ref);
            }
View Full Code Here

    }
    if (credentialsProvider != null) {
      fetch.setCredentialsProvider(credentialsProvider);
    }
    fetch.setRefSpecs(specs);
    FetchResult fetchRes = fetch.call();
    return fetchRes;
  }
View Full Code Here

        }

        logger.debug("checking {} remote {} for ref updates", repositoryName, mirror.getName());
        final boolean testing = false;
        Git git = new Git(repository);
        FetchResult result = git.fetch().setRemote(mirror.getName()).setDryRun(testing).call();
        Collection<TrackingRefUpdate> refUpdates = result.getTrackingRefUpdates();
        if (refUpdates.size() > 0) {
          ReceiveCommand ticketBranchCmd = null;
          for (TrackingRefUpdate ru : refUpdates) {
            StringBuilder sb = new StringBuilder();
            sb.append("updated mirror ");
View Full Code Here

    if (thin != null)
      fetch.setThin(thin.booleanValue());
    if (quiet == null || !quiet.booleanValue())
      fetch.setProgressMonitor(new TextProgressMonitor());

    FetchResult result = fetch.call();
    if (result.getTrackingRefUpdates().isEmpty())
      return;

    showFetchResult(result);
  }
View Full Code Here

    RemoteConfig rc = new RemoteConfig(config, "origin");
    rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath()));
    rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    rc.update(config);
    config.save();
    FetchResult res = localGit.fetch().setRemote("origin").call();
    assertFalse(res.getTrackingRefUpdates().isEmpty());
    rup = localRepository.updateRef("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.forceUpdate();
    rup = localRepository.updateRef(Constants.HEAD);
    rup.link("refs/heads/master");
View Full Code Here

    if (remoteBranchName == null)
      remoteBranchName = branchName;

    final boolean isRemote = !remote.equals("."); //$NON-NLS-1$
    String remoteUri;
    FetchResult fetchRes;
    if (isRemote) {
      remoteUri = repoConfig.getString(
          ConfigConstants.CONFIG_REMOTE_SECTION, remote,
          ConfigConstants.CONFIG_KEY_URL);
      if (remoteUri == null) {
        String missingKey = ConfigConstants.CONFIG_REMOTE_SECTION + DOT
            + remote + DOT + ConfigConstants.CONFIG_KEY_URL;
        throw new InvalidConfigurationException(MessageFormat.format(
            JGitText.get().missingConfigurationForKey, missingKey));
      }

      if (monitor.isCancelled())
        throw new CanceledException(MessageFormat.format(
            JGitText.get().operationCanceled,
            JGitText.get().pullTaskName));

      FetchCommand fetch = new FetchCommand(repo);
      fetch.setRemote(remote);
      fetch.setProgressMonitor(monitor);
      configure(fetch);

      fetchRes = fetch.call();
    } else {
      // we can skip the fetch altogether
      remoteUri = "local repository";
      fetchRes = null;
    }

    monitor.update(1);

    if (monitor.isCancelled())
      throw new CanceledException(MessageFormat.format(
          JGitText.get().operationCanceled,
          JGitText.get().pullTaskName));

    // we check the updates to see which of the updated branches
    // corresponds
    // to the remote branch name
    AnyObjectId commitToMerge;
    if (isRemote) {
      Ref r = null;
      if (fetchRes != null) {
        r = fetchRes.getAdvertisedRef(remoteBranchName);
        if (r == null)
          r = fetchRes.getAdvertisedRef(Constants.R_HEADS
              + remoteBranchName);
      }
      if (r == null)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().couldNotGetAdvertisedRef, remoteBranchName));
View Full Code Here

  public Git call() throws GitAPIException, InvalidRemoteException,
      org.eclipse.jgit.api.errors.TransportException {
    try {
      URIish u = new URIish(uri);
      Repository repository = init(u);
      FetchResult result = fetch(repository, u);
      if (!noCheckout)
        checkout(repository, result);
      return new Git(repository);
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
View Full Code Here

    assertEquals(originalId, db.resolve(tagName));

    remoteGit.commit().setMessage("commit 2").call();
    remoteGit.tag().setName(tagName).setForceUpdate(true).call();

    FetchResult result = git.fetch().setRemote("test").setRefSpecs(spec)
        .setTagOpt(TagOpt.AUTO_FOLLOW).call();

    Collection<TrackingRefUpdate> refUpdates = result
        .getTrackingRefUpdates();
    assertEquals(1, refUpdates.size());
    TrackingRefUpdate update = refUpdates.iterator().next();
    assertEquals("refs/heads/master", update.getRemoteName());
View Full Code Here

    remoteGit.commit().setMessage("commit 2").call();
    Ref tagRef2 = remoteGit.tag().setName(tagName).setForceUpdate(true)
        .call();

    FetchResult result = git.fetch().setRemote("test").setRefSpecs(spec)
        .setTagOpt(TagOpt.FETCH_TAGS).call();
    TrackingRefUpdate update = result.getTrackingRefUpdate(Constants.R_TAGS
        + tagName);
    assertEquals(RefUpdate.Result.FORCED, update.getResult());
    assertEquals(tagRef2.getObjectId(), db.resolve(tagName));
  }
View Full Code Here

TOP

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

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.