Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.CheckoutCommand


   public static Ref checkout(final Git git, final String remote, final boolean createBranch,
            final SetupUpstreamMode mode, final boolean force)
            throws GitAPIException
   {
      CheckoutCommand checkout = git.checkout();
      checkout.setCreateBranch(createBranch);
      checkout.setName(remote);
      checkout.setForce(force);
      checkout.setUpstreamMode(mode);
      return checkout.call();
   }
View Full Code Here


   public static Ref checkout(final Git git, final Ref localRef, final boolean createBranch,
            final SetupUpstreamMode mode, final boolean force)
            throws GitAPIException
   {
      CheckoutCommand checkout = git.checkout();
      checkout.setName(Repository.shortenRefName(localRef.getName()));
      checkout.setForce(force);
      checkout.setUpstreamMode(mode);
      return checkout.call();
   }
View Full Code Here

            project.close(closeMonitor);
          }
          closeMonitor.done();
        }

        CheckoutCommand co = new Git(repository).checkout();
        co.setName(target);

        try {
          co.call();
        } catch (CheckoutConflictException e) {
          return;
        } catch (JGitInternalException e) {
          throw new CoreException(Activator.error(e.getMessage(), e));
        } catch (GitAPIException e) {
          throw new CoreException(Activator.error(e.getMessage(), e));
        } finally {
          BranchOperation.this.result = co.getResult();
        }
        if (result.getStatus() == Status.NONDELETED)
          retryDelete(result.getUndeletedList());
        pm.worked(1);

        List<String> pathsToHandle = new ArrayList<String>();
        pathsToHandle.addAll(co.getResult().getModifiedList());
        pathsToHandle.addAll(co.getResult().getRemovedList());
        pathsToHandle.addAll(co.getResult().getConflictList());
        IProject[] refreshProjects = ProjectUtil
            .getProjectsContaining(repository, pathsToHandle);
        ProjectUtil.refreshValidProjects(refreshProjects, delete,
            new SubProgressMonitor(pm, 1));
        pm.worked(1);
View Full Code Here

    CreateLocalBranchOperation bop = new CreateLocalBranchOperation(
        repository, textForBranch, commit);
    bop.execute(monitor);

    if (doCheckout) {
      CheckoutCommand co = new Git(repository).checkout();
      try {
        co.setName(textForBranch).call();
      } catch (CheckoutConflictException e) {
        final CheckoutResult result = co.getResult();

        if (result.getStatus() == Status.CONFLICTS) {
          final Shell shell = getWizard().getContainer().getShell();

          shell.getDisplay().asyncExec(new Runnable() {
View Full Code Here

        .splitResourcesByRepository(files);
    for (Entry<Repository, Collection<String>> entry : pathsByRepository.entrySet()) {
      Repository repository = entry.getKey();
      ResourceUtil.saveLocalHistory(repository);
      Collection<String> paths = entry.getValue();
      CheckoutCommand checkoutCommand = new Git(repository).checkout();
      checkoutCommand.setStartPoint(this.revision);
      if (paths.isEmpty() || paths.contains("")) //$NON-NLS-1$
        checkoutCommand.setAllPaths(true);
      else
        for (String path : paths)
          checkoutCommand.addPath(path);
      checkoutCommand.call();
    }
  }
View Full Code Here

  }

  private void replaceWith(String[] files, boolean headRevision) {
    if (files == null || files.length == 0)
      return;
    CheckoutCommand checkoutCommand = new Git(currentRepository).checkout();
    if (headRevision)
      checkoutCommand.setStartPoint(Constants.HEAD);
    for (String path : files)
      checkoutCommand.addPath(path);
    try {
      checkoutCommand.call();
    } catch (Exception e) {
      Activator.handleError(UIText.StagingView_checkoutFailed, e, true);
    }
  }
View Full Code Here

   public static Ref checkout(final Git git, final String remote, final boolean createBranch,
            final SetupUpstreamMode mode, final boolean force)
            throws JGitInternalException,
            RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException
   {
      CheckoutCommand checkout = git.checkout();
      checkout.setCreateBranch(createBranch);
      checkout.setName(remote);
      checkout.setForce(force);
      checkout.setUpstreamMode(mode);
      return checkout.call();
   }
View Full Code Here

   public static Ref checkout(final Git git, final Ref remote, final boolean createBranch,
            final SetupUpstreamMode mode, final boolean force)
            throws JGitInternalException,
            RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException
   {
      CheckoutCommand checkout = git.checkout();
      checkout.setName(remote.getName());
      checkout.setForce(force);
      checkout.setUpstreamMode(mode);
      return checkout.call();
   }
View Full Code Here

    this.force = force;
  }

  @Override
  public void execute() throws BuildException {
    CheckoutCommand checkout;
    try {
      Repository repo = new FileRepositoryBuilder().readEnvironment()
          .findGitDir(src).build();
      checkout = new Git(repo).checkout();
    } catch (IOException e) {
      throw new BuildException("Could not access repository " + src, e);
    }

    try {
      checkout.setCreateBranch(createBranch).setForce(force)
          .setName(branch);
      checkout.call();
    } catch (Exception e) {
      throw new BuildException("Could not checkout repository " + src, e);
    }
  }
View Full Code Here

        }
        if (Objects.equals(current, branch)) {
            return;
        }
        // lets check if the branch exists
        CheckoutCommand command = git.checkout().setName(branch);
            boolean exists = localBranchExists(branch);
            if (!exists) {
                command = command.setCreateBranch(true).setForce(true).
                        setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK).
                        setStartPoint(getRemote() + "/" + branch);
        }
        Ref ref = command.call();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Checked out branch " + branch + " with results " + ref.getName());
        }
        configureBranch(branch);
    }
View Full Code Here

TOP

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

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.