Examples of CheckOutCommand


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 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

Examples of org.eclipse.jgit.api.CheckoutCommand

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

Examples of org.eclipse.jgit.api.CheckoutCommand

    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

Examples of org.eclipse.jgit.api.CheckoutCommand

      final ObjectId head = db.resolve(Constants.HEAD);
      if (head == null)
        throw die(CLIText.get().onBranchToBeBorn);
    }

    CheckoutCommand command = new Git(db).checkout();
    if (paths.size() > 0) {
      command.setStartPoint(name);
      for (String path : paths)
        command.addPath(path);
    } else {
      command.setCreateBranch(createBranch);
      command.setName(name);
      command.setForce(force);
    }
    try {
      String oldBranch = db.getBranch();
      Ref ref = command.call();
      if (ref == null)
        return;
      if (Repository.shortenRefName(ref.getName()).equals(oldBranch)) {
        outw.println(MessageFormat.format(
            CLIText.get().alreadyOnBranch,
View Full Code Here

Examples of org.eclipse.jgit.api.CheckoutCommand

    assertTrue(db.getFS().canExecute(file));

    writeTrashFile("file.txt", "b");

    // Switch branches
    CheckoutCommand checkout = git.checkout().setName("b1");
    try {
      checkout.call();
      fail("Checkout exception not thrown");
    } catch (org.eclipse.jgit.api.errors.CheckoutConflictException e) {
      CheckoutResult result = checkout.getResult();
      assertNotNull(result);
      assertNotNull(result.getConflictList());
      assertEquals(1, result.getConflictList().size());
      assertTrue(result.getConflictList().contains("file.txt"));
    }
View Full Code Here

Examples of org.eclipse.jgit.api.CheckoutCommand

        }

        Git git = new Git(FileRepositoryBuilder.create(gitDir));
        if (paths != null) {
          Set<String> toRemove = new HashSet<String>();
          CheckoutCommand checkout = git.checkout();
          for (int i = 0; i < paths.length(); i++) {
            String p = paths.getString(i);
            if (removeUntracked && !isInIndex(git.getRepository(), p))
              toRemove.add(p);
            checkout.addPath(p);
          }
          checkout.call();
          for (String p : toRemove) {
            File f = new File(git.getRepository().getWorkTree(), p);
            f.delete();
          }
          return true;
        } else if (tag != null && branch != null) {
          CheckoutCommand co = git.checkout();
          try {
            co.setName(branch).setStartPoint(tag).setCreateBranch(true).call();
            return true;
          } catch (RefNotFoundException e) {
            String msg = NLS.bind("Tag not found: {0}", EncodingUtils.encodeForHTML(tag));
            return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, e));
          } catch (GitAPIException e) {
            if (org.eclipse.jgit.api.CheckoutResult.Status.CONFLICTS.equals(co.getResult().getStatus())) {
              return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_CONFLICT,
                  "Checkout aborted.", e));
            }
            // TODO: handle other exceptions
          }
        } else if (branch != null) {

          if (!isLocalBranch(git, branch)) {
            String msg = NLS.bind("{0} is not a branch.", EncodingUtils.encodeForHTML(branch));
            return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, null));
          }

          CheckoutCommand co = git.checkout();
          try {
            co.setName(Constants.R_HEADS + branch).call();
            return true;
          } catch (CheckoutConflictException e) {
            return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_CONFLICT,
                "Checkout aborted.", e));
          } catch (RefNotFoundException e) {
View Full Code Here

Examples of org.eclipse.jgit.api.CheckoutCommand

   @Override
   public 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

Examples of org.eclipse.jgit.api.CheckoutCommand

   @Override
   public Ref checkout(final Git git, final Ref localRef, 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

Examples of org.eclipse.jgit.api.CheckoutCommand

   @Override
   public 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

Examples of org.eclipse.jgit.api.CheckoutCommand

   @Override
   public Ref checkout(final Git git, final Ref localRef, 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
TOP
Copyright © 2018 www.massapi.com. 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.