Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.CheckoutCommand


            // Check branch
            boolean pull = true;
            String currentBranch = repository.getBranch();
            if (branch != null && !branch.equals(currentBranch)) {
                CheckoutCommand checkout = git.checkout();
                if (!branchExists(git, branch)) {
                    checkout.setCreateBranch(true);
                    pull = false;
                }
                checkout.setName(branch);
                checkout.call();
            }
            if (pull) {
                git.pull().call();
            } else {
                git.fetch().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

   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

   public static Ref checkout(Git git, String remote, boolean createBranch, SetupUpstreamMode mode, 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

   @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

   @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

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

    CheckoutCommand command = new Git(db).checkout();
    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

   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

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.