Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.CloneCommand


  @Override
  public void execute() throws BuildException {
    log("Cloning repository " + uri);
   
    CloneCommand clone = Git.cloneRepository();
    try {
      clone.setURI(uri).setDirectory(destination).setBranch(branch).setBare(bare);
      clone.call().getRepository().close();
    } catch (Exception e) {
      log("Could not clone repository: " + e, e, Project.MSG_ERR);
      throw new BuildException("Could not clone repository: " + e.getMessage(), e);
    }
  }
View Full Code Here


*/
public abstract class GitUtils
{
   public static Git clone(final DirectoryResource dir, final String repoUri) throws GitAPIException
   {
      CloneCommand clone = Git.cloneRepository().setURI(repoUri)
               .setDirectory(dir.getUnderlyingResourceObject());
      Git git = clone.call();
      return git;
   }
View Full Code Here

{
  
   @Override
   public Git clone(final DirectoryResource dir, final String repoUri) throws GitAPIException
   {
      CloneCommand clone = Git.cloneRepository().setURI(repoUri)
               .setDirectory(dir.getUnderlyingResourceObject());
      Git git = clone.call();
      return git;
   }
View Full Code Here

*/
public abstract class GitUtils
{
   public static Git clone(final DirectoryResource dir, final String repoUri) throws GitAPIException
   {
      CloneCommand clone = Git.cloneRepository().setURI(repoUri)
               .setDirectory(dir.getUnderlyingResourceObject());
      Git git = clone.call();
      return git;
   }
View Full Code Here

    // clone the repository
    try {
      Repository canonical = getRepository(repository.name);
      File folder = new File(repositoryManager.getRepositoriesFolder(), cloneName);
      CloneCommand clone = new CloneCommand();
      clone.setBare(true);

      // fetch branches with exclusions
      Collection<Ref> branches = canonical.getRefDatabase().getRefs(Constants.R_HEADS).values();
      List<String> branchesToClone = new ArrayList<String>();
      for (Ref branch : branches) {
        String name = branch.getName();
        if (name.startsWith(Constants.R_TICKET)) {
          // exclude ticket branches
          continue;
        }
        branchesToClone.add(name);
      }
      clone.setBranchesToClone(branchesToClone);
      clone.setURI(fromUrl);
      clone.setDirectory(folder);
      Git git = clone.call();

      // fetch tags
      FetchCommand fetch  = git.fetch();
      fetch.setRefSpecs(new RefSpec("+refs/tags/*:refs/tags/*"));
      fetch.call();
 
View Full Code Here

      File gitDir = FileKey.resolve(new File(repositoriesFolder, name), FS.DETECTED);
      Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
      result.fetchResult = fetchRepository(credentialsProvider, repository);
      repository.close();
    } else {
      CloneCommand clone = new CloneCommand();
      clone.setBare(bare);
      clone.setCloneAllBranches(true);
      clone.setURI(fromUrl);
      clone.setDirectory(folder);
      if (credentialsProvider != null) {
        clone.setCredentialsProvider(credentialsProvider);
      }
      Repository repository = clone.call().getRepository();

      // Now we have to fetch because CloneCommand doesn't fetch
      // refs/notes nor does it allow manual RefSpec.
      result.createdRepository = true;
      result.fetchResult = fetchRepository(credentialsProvider, repository);
View Full Code Here

                try {
                    git = Git.open(workingDir);
                    git.pull().setCredentialsProvider(user).call();
                } catch (Exception e) {
                    workspaceProvider.cleanWorkingDirectory();
                    CloneCommand gitCommand = Git.cloneRepository()
                            .setURI(gitUrl)
                            .setDirectory(workingDir)
                            .setProgressMonitor(new TextProgressMonitor())
                            .setCredentialsProvider(user);
                    git = gitCommand.call();
                }
            } else {
                git = Git.cloneRepository()
                        .setURI(gitUrl)
                        .setDirectory(workingDir)
View Full Code Here

*/
public abstract class GitUtils
{
   public static Git clone(final DirectoryResource dir, final String repoUri) throws IOException
   {
      CloneCommand clone = Git.cloneRepository().setURI(repoUri)
               .setDirectory(dir.getUnderlyingResourceObject());
      Git git = clone.call();
      return git;
   }
View Full Code Here

    // clone the repository
    try {
      Repository canonical = getRepository(repository.name);
      File folder = new File(repositoryManager.getRepositoriesFolder(), cloneName);
      CloneCommand clone = new CloneCommand();
      clone.setBare(true);

      // fetch branches with exclusions
      Collection<Ref> branches = canonical.getRefDatabase().getRefs(Constants.R_HEADS).values();
      List<String> branchesToClone = new ArrayList<String>();
      for (Ref branch : branches) {
        String name = branch.getName();
        if (name.startsWith(Constants.R_TICKET)) {
          // exclude ticket branches
          continue;
        }
        branchesToClone.add(name);
      }
      clone.setBranchesToClone(branchesToClone);
      clone.setURI(fromUrl);
      clone.setDirectory(folder);
      Git git = clone.call();

      // fetch tags
      FetchCommand fetch  = git.fetch();
      fetch.setRefSpecs(new RefSpec("+refs/tags/*:refs/tags/*"));
      fetch.call();
 
View Full Code Here

      File gitDir = FileKey.resolve(new File(repositoriesFolder, name), FS.DETECTED);
      Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
      result.fetchResult = fetchRepository(credentialsProvider, repository);
      repository.close();
    } else {
      CloneCommand clone = new CloneCommand();
      clone.setBare(bare);
      clone.setCloneAllBranches(true);
      clone.setURI(fromUrl);
      clone.setDirectory(folder);
      if (credentialsProvider != null) {
        clone.setCredentialsProvider(credentialsProvider);
      }
      Repository repository = clone.call().getRepository();

      // Now we have to fetch because CloneCommand doesn't fetch
      // refs/notes nor does it allow manual RefSpec.
      result.createdRepository = true;
      result.fetchResult = fetchRepository(credentialsProvider, repository);
View Full Code Here

TOP

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

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.