Exemple #1
0
 @Override
 protected void run() throws Exception {
   CheckoutCommand command = new Git(db).checkout();
   command.setCreateBranch(createBranch);
   command.setName(name);
   command.setForce(force);
   command.call();
 }
Exemple #2
0
 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();
 }
Exemple #3
0
 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();
 }
Exemple #4
0
 public void branchesCheckout() {
   String branchName = "";
   Set<Entry<String, Ref>> refs = repository.getAllRefs().entrySet();
   for (Entry<String, Ref> ref : refs) {
     if (ref.getKey().startsWith(Constants.R_REMOTES) && !ref.getKey().contains(Constants.HEAD)) {
       branchName = ref.getValue().getName().split(Constants.R_REMOTES)[1];
       // TODO: replace with logging
       System.out.println(
           "Trying to checkout branch: "
               + branchName
               + " ("
               + branchName.split("origin/")[1]
               + ")");
       CheckoutCommand checkoutCommand = this.git.checkout();
       checkoutCommand.setForce(true);
       checkoutCommand.setCreateBranch(true);
       checkoutCommand.setUpstreamMode(SetupUpstreamMode.TRACK);
       checkoutCommand.setName(branchName.split("origin/")[1]);
       checkoutCommand.setStartPoint(branchName);
       try {
         checkoutCommand.call();
         // TODO: replace with logging
         // println "Successfully checked out branch " + branchName;
       } catch (RefAlreadyExistsException e) {
         // TODO: replace with logging
         // println "Skipping branch (already exists): " + branchName;
       } catch (RefNotFoundException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       } catch (InvalidRefNameException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       } catch (GitAPIException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
 }