Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2012 Red Hat, Inc. and/or its affiliates.
  *
  * Licensed under the Eclipse Public License version 1.0, available at
  * http://www.eclipse.org/legal/epl-v10.html
  */
 
 package org.jboss.forge.git;
 

Author(s):
Lincoln Baxter, III
Jevgeni Zelenkov
@Alias("git")
public class Git implements Plugin
   @Inject
   private Shell shell;
   @Inject
   private Event<InstallFacetsevent;
   @Inject
   private Project project;
   public void setup(PipeOut out)
   {
      if (!.hasFacet(GitFacet.class))
         .fire(new InstallFacets(GitFacet.class));
      else
         ShellMessages.info(out"Git repository exists already.");
   }
   @Command("clone")
   public void gitClone(PipeOut out,
            @Option(description = "git repo uri"String uri,
            @Option(description = "target directory"Resource<?> folderthrows Exception
   {
      if (folder instanceof FileResource<?>)
      {
         if (!folder.exists())
         {
            ((FileResource<?>) folder).mkdirs();
            folder = folder.reify(DirectoryResource.class);
         }
         org.eclipse.jgit.api.Git clone = GitUtils.clone((DirectoryResourcefolderuri);
         GitUtils.close(clone);
         .setCurrentResource(folder);
      }
      else
      {
         throw new RuntimeException();
      }
   }
   @Command("git-checkout")
   public void gitCheckout(
            PipeOut out,
            @Option(description = "branch name", defaultValue = "master"String ref,
            @Option(name = "createBranch", shortName = "b"boolean createBranch,
            @Option(name = "track", shortName = "t", description = "remote tracking mode", defaultValue = "master"SetupUpstreamMode mode,
            @Option(name = "force"boolean forcethrows Exception
   {
      org.eclipse.jgit.api.Git git = GitUtils.git(.getCurrentProject().getProjectRoot());
      GitUtils.checkout(gitrefcreateBranchmodeforce);
      GitUtils.close(git);
   }
New to GrepCode? Check out our FAQ X