Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.CloneCommand


    // fork from original to a temporary bare repo
    File refChecks = new File(GitBlitSuite.REPOSITORIES, forkName);
    if (refChecks.exists()) {
      FileUtils.delete(refChecks, FileUtils.RECURSIVE);
    }
    CloneCommand clone = Git.cloneRepository();
    clone.setURI(url + "/" + originName);
    clone.setDirectory(refChecks);
    clone.setBare(true);
    clone.setCloneAllBranches(true);
    clone.setCredentialsProvider(cp);
    GitBlitSuite.close(clone.call());

    // elevate repository to clone permission
    RepositoryModel model = repositories().getRepositoryModel(forkName);
    switch (permission) {
      case VIEW:
        model.accessRestriction = AccessRestrictionType.CLONE;
        break;
      case CLONE:
        model.accessRestriction = AccessRestrictionType.CLONE;
        break;
      default:
        model.accessRestriction = AccessRestrictionType.PUSH;
    }
    model.authorizationControl = AuthorizationControl.NAMED;

    // grant user specified
    user.setRepositoryPermission(model.name, permission);

    gitblit().addUser(user);
    repositories().updateRepositoryModel(model.name, model, false);

    // clone temp bare repo to working copy
    File local = new File(GitBlitSuite.REPOSITORIES, workingCopy);
    if (local.exists()) {
      FileUtils.delete(local, FileUtils.RECURSIVE);
    }
    clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/{1}", url, model.name));
    clone.setDirectory(local);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    clone.setCredentialsProvider(cp);

    try {
      GitBlitSuite.close(clone.call());
    } catch (GitAPIException e) {
      if (permission.atLeast(AccessPermission.CLONE)) {
        throw e;
      } else {
        // close serving repository
View Full Code Here


    RepositoryModel model = repositories().getRepositoryModel("ticgit.git");
    model.accessRestriction = AccessRestrictionType.PUSH;
    model.authorizationControl = AuthorizationControl.NAMED;
    repositories().updateRepositoryModel(model.name, model, false);

    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
    clone.setDirectory(ticgitFolder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    GitBlitSuite.close(clone.call());
    assertTrue(true);

    // restore anonymous repository access
    model.accessRestriction = AccessRestrictionType.NONE;
    model.authorizationControl = AuthorizationControl.NAMED;
View Full Code Here

    repositories().updateRepositoryModel(model.name, model, false);

    // delete any existing working folder
    boolean cloned = false;
    try {
      CloneCommand clone = Git.cloneRepository();
      clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
      clone.setDirectory(ticgit2Folder);
      clone.setBare(false);
      clone.setCloneAllBranches(true);
      GitBlitSuite.close(clone.call());
      cloned = true;
    } catch (Exception e) {
      // swallow the exception which we expect
    }
View Full Code Here

    RepositoryModel model = repositories().getRepositoryModel("ticgit.git");
    model.accessRestriction = AccessRestrictionType.NONE;
    model.authorizationControl = AuthorizationControl.NAMED;
    repositories().updateRepositoryModel(model.name, model, false);

    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
    clone.setDirectory(ticgitFolder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    GitBlitSuite.close(clone.call());
    assertTrue(true);

    Git git = Git.open(ticgitFolder);
    File file = new File(ticgitFolder, "TODO");
    OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
View Full Code Here

    RepositoryModel model = repositories().getRepositoryModel("ticgit.git");
    model.accessRestriction = AccessRestrictionType.PUSH;
    model.authorizationControl = AuthorizationControl.NAMED;
    repositories().updateRepositoryModel(model.name, model, false);

    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
    clone.setDirectory(ticgitFolder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    GitBlitSuite.close(clone.call());
    assertTrue(true);

    Git git = Git.open(ticgitFolder);
    File file = new File(ticgitFolder, "TODO");
    OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
View Full Code Here

    GitBlitSuite.close(jgitFolder);
    if (jgitFolder.exists()) {
      FileUtils.delete(jgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
    }

    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/test/jgit.git", url));
    clone.setDirectory(jgitFolder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    GitBlitSuite.close(clone.call());
    assertTrue(true);

    // freeze repo
    RepositoryModel model = repositories().getRepositoryModel("test/jgit.git");
    model.isFrozen = true;
View Full Code Here

    GitBlitSuite.close(jgit2Folder);
    if (jgit2Folder.exists()) {
      FileUtils.delete(jgit2Folder, FileUtils.RECURSIVE | FileUtils.RETRY);
    }

    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/working/jgit", url));
    clone.setDirectory(jgit2Folder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    GitBlitSuite.close(clone.call());
    assertTrue(true);

    Git git = Git.open(jgit2Folder);
    File file = new File(jgit2Folder, "NONBARE");
    OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
View Full Code Here

    repositories().updateRepositoryModel(model.name, model, false);

    JschConfigTestSessionFactory sessionFactory = new JschConfigTestSessionFactory(roKeyPair);
    SshSessionFactory.setInstance(sessionFactory);

    CloneCommand clone = Git.cloneRepository();
    clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password));
    clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
    clone.setDirectory(ticgitFolder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    Git git = clone.call();
    List<RevCommit> commits = JGitUtils.getRevLog(git.getRepository(), 10);
    GitBlitSuite.close(git);
    assertEquals(10, commits.size());

    // restore anonymous repository access
View Full Code Here

         cloneFolder.mkdirs();
      }
      Git clone = null;
      try
      {
         CloneCommand cloneCommand = Git.cloneRepository().setURI(uri.getValue())
                  .setDirectory(cloneFolder.getUnderlyingResourceObject());
         cloneCommand.setProgressMonitor(new ProgressMonitorAdapter(context.getProgressMonitor()));
         clone = cloneCommand.call();
      }
      finally
      {
         gitUtils.close(clone);
      }
View Full Code Here

    try {
      File cloneFolder = new File(clone.getContentLocation().getPath());
      if (!cloneFolder.exists()) {
        cloneFolder.mkdir();
      }
      CloneCommand cc = Git.cloneRepository();
      cc.setProgressMonitor(gitMonitor);
      cc.setBare(false);
      cc.setCredentialsProvider(credentials);
      cc.setDirectory(cloneFolder);
      cc.setRemote(Constants.DEFAULT_REMOTE_NAME);
      cc.setURI(clone.getUrl());
      if (this.cookie != null) {
        cc.setTransportConfigCallback(new TransportConfigCallback() {
          @Override
          public void configure(Transport t) {
            if (t instanceof TransportHttp && cookie != null) {
              HashMap<String, String> map = new HashMap<String, String>();
              map.put(GitConstants.KEY_COOKIE, cookie.getName() + "=" + cookie.getValue());
              ((TransportHttp) t).setAdditionalHeaders(map);
            }
          }
        });
      }
      Git git = cc.call();

      if (monitor.isCanceled()) {
        return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled");
      }
      // Configure the clone, see Bug 337820
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.