Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.FetchCommand


  private List<RefSpec> toget;

  @Override
  protected void run() throws Exception {
    Git git = new Git(db);
    FetchCommand fetch = git.fetch();
    if (fsck != null)
      fetch.setCheckFetchedObjects(fsck.booleanValue());
    if (prune != null)
      fetch.setRemoveDeletedRefs(prune.booleanValue());
    if (toget != null)
      fetch.setRefSpecs(toget);
    if (tags != null) {
      fetch.setTagOpt(tags.booleanValue() ? TagOpt.FETCH_TAGS
          : TagOpt.NO_TAGS);
    }
    if (0 <= timeout)
      fetch.setTimeout(timeout);
    fetch.setDryRun(dryRun);
    fetch.setRemote(remote);
    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


    ProgressMonitor gitMonitor = new EclipseGitProgressTransformer(monitor);
    Repository db = null;
    try {
      db = getRepository();
      Git git = new Git(db);
      FetchCommand fc = git.fetch();
      fc.setProgressMonitor(gitMonitor);

      RemoteConfig remoteConfig = new RemoteConfig(git.getRepository().getConfig(), remote);
      credentials.setUri(remoteConfig.getURIs().get(0));
      if (this.cookie != null) {
        fc.setTransportConfigCallback(new TransportConfigCallback() {
          @Override
          public void configure(Transport t) {
            if (t instanceof TransportHttp && cookie != null) {
              HashMap<String, String> map = new HashMap<String, String>();
              map.put(GitConstants.KEY_COOKIE, cookie.getName() + "=" + cookie.getValue());
              ((TransportHttp) t).setAdditionalHeaders(map);
            }
          }
        });
      }
      fc.setCredentialsProvider(credentials);
      fc.setRemote(remote);
      if (branch != null) {
        // refs/heads/{branch}:refs/remotes/{remote}/{branch}
        String remoteBranch = branch;
        if (branch.startsWith("for/")) {
          remoteBranch = branch.substring(4);
        }

        RefSpec spec = new RefSpec(Constants.R_HEADS + remoteBranch + ":" + Constants.R_REMOTES + remote + "/" + branch); //$NON-NLS-1$ //$NON-NLS-2$
        spec = spec.setForceUpdate(force);
        fc.setRefSpecs(spec);
      }
      FetchResult fetchResult = fc.call();
      if (monitor.isCanceled()) {
        return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled");
      }
      GitJobUtils.packRefs(db, gitMonitor);
      if (monitor.isCanceled()) {
View Full Code Here

   public FetchResult fetch(final Git git, final String remote, final String refSpec, final int timeout,
            final boolean fsck, final boolean dryRun,
            final boolean thin,
            final boolean prune) throws GitAPIException
   {
      FetchCommand fetch = git.fetch();
      fetch.setCheckFetchedObjects(fsck);
      fetch.setRemoveDeletedRefs(prune);
      if (refSpec != null)
         fetch.setRefSpecs(new RefSpec(refSpec));
      if (timeout >= 0)
         fetch.setTimeout(timeout);
      fetch.setDryRun(dryRun);
      fetch.setRemote(remote);
      fetch.setThin(thin);
      fetch.setProgressMonitor(new TextProgressMonitor());

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

   public FetchResult fetch(final Git git, final String remote, final String refSpec, final int timeout,
            final boolean fsck, final boolean dryRun,
            final boolean thin,
            final boolean prune) throws GitAPIException
   {
      FetchCommand fetch = git.fetch();
      fetch.setCheckFetchedObjects(fsck);
      fetch.setRemoveDeletedRefs(prune);
      if (refSpec != null)
         fetch.setRefSpecs(new RefSpec(refSpec));
      if (timeout >= 0)
         fetch.setTimeout(timeout);
      fetch.setDryRun(dryRun);
      fetch.setRemote(remote);
      fetch.setThin(thin);
      fetch.setProgressMonitor(new TextProgressMonitor());

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

   public static FetchResult fetch(final Git git, final String remote, final String refSpec, final int timeout,
            final boolean fsck, final boolean dryRun,
            final boolean thin,
            final boolean prune) throws GitAPIException
   {
      FetchCommand fetch = git.fetch();
      fetch.setCheckFetchedObjects(fsck);
      fetch.setRemoveDeletedRefs(prune);
      if (refSpec != null)
         fetch.setRefSpecs(new RefSpec(refSpec));
      if (timeout >= 0)
         fetch.setTimeout(timeout);
      fetch.setDryRun(dryRun);
      fetch.setRemote(remote);
      fetch.setThin(thin);
      fetch.setProgressMonitor(new TextProgressMonitor());

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

    IProgressMonitor actMonitor = monitor;
    if (actMonitor == null)
      actMonitor = new NullProgressMonitor();
    EclipseGitProgressTransformer gitMonitor = new EclipseGitProgressTransformer(
        actMonitor);
    FetchCommand command;
    if (rc == null)
      command = new Git(repository).fetch().setRemote(
          uri.toPrivateString()).setRefSpecs(specs);
    else
      command = new Git(repository).fetch().setRemote(rc.getName());
    command.setCredentialsProvider(credentialsProvider).setTimeout(timeout)
        .setDryRun(dryRun).setProgressMonitor(gitMonitor);
    if (tagOpt != null)
      command.setTagOpt(tagOpt);
    try {
      operationResult = command.call();
    } catch (JGitInternalException e) {
      throw new InvocationTargetException(e.getCause() != null ? e
          .getCause() : e);
    } catch (Exception e) {
      throw new InvocationTargetException(e);
View Full Code Here

   public static FetchResult fetch(final Git git, final String remote, final String refSpec, final int timeout,
            final boolean fsck, final boolean dryRun,
            final boolean thin,
            final boolean prune) throws JGitInternalException, InvalidRemoteException
   {
      FetchCommand fetch = git.fetch();
      fetch.setCheckFetchedObjects(fsck);
      fetch.setRemoveDeletedRefs(prune);
      if (refSpec != null)
         fetch.setRefSpecs(new RefSpec(refSpec));
      if (timeout >= 0)
         fetch.setTimeout(timeout);
      fetch.setDryRun(dryRun);
      fetch.setRemote(remote);
      fetch.setThin(thin);
      fetch.setProgressMonitor(new TextProgressMonitor());

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

TOP

Related Classes of org.eclipse.jgit.api.FetchCommand

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.