Examples of CloneCommand


Examples of org.eclipse.jgit.api.CloneCommand

    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);
      clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider("bogus", "bogus"));
      GitBlitSuite.close(clone.call());
      cloned = true;
    } catch (Exception e) {
      // swallow the exception which we expect
    }
View Full Code Here

Examples of org.eclipse.jgit.api.CloneCommand

    FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);

    // 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);
      clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.username, user.password));
      GitBlitSuite.close(clone.call());
      cloned = true;
    } catch (Exception e) {
      // swallow the exception which we expect
    }

    assertFalse("Unauthorized login cloned a repository?!", cloned);

    FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);

    // switch to authenticated
    model.authorizationControl = AuthorizationControl.AUTHENTICATED;
    repositories().updateRepositoryModel(model.name, model, false);

    // try clone again
    cloned = false;
    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
    clone.setDirectory(ticgit2Folder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.username, user.password));
    GitBlitSuite.close(clone.call());
    cloned = true;

    assertTrue("Authenticated login could not clone!", cloned);

    FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
View Full Code Here

Examples of org.eclipse.jgit.api.CloneCommand

    RepositoryModel model = repositories().getRepositoryModel("ticgit.git");
    model.accessRestriction = AccessRestrictionType.NONE;
    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);
    clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
    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

Examples of org.eclipse.jgit.api.CloneCommand

    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);
    clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
    GitBlitSuite.close(clone.call());
    assertTrue(true);

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

Examples of org.eclipse.jgit.api.CloneCommand

    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);
    clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
    GitBlitSuite.close(clone.call());
    assertTrue(true);

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

Examples of org.eclipse.jgit.api.CloneCommand

    }
  }

  @Test
  public void testPushToNonBareRepository() throws Exception {
    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/working/jgit", url));
    clone.setDirectory(jgit2Folder);
    clone.setBare(false);
    clone.setCloneAllBranches(true);
    clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
    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

Examples of org.eclipse.jgit.api.CloneCommand

    // fork from original to a temporary bare repo
    File verification = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-committer.git");
    if (verification.exists()) {
      FileUtils.delete(verification, FileUtils.RECURSIVE);
    }
    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
    clone.setDirectory(verification);
    clone.setBare(true);
    clone.setCloneAllBranches(true);
    clone.setCredentialsProvider(cp);
    GitBlitSuite.close(clone.call());

    // require push permissions and committer verification
    RepositoryModel model = repositories().getRepositoryModel("refchecks/verify-committer.git");
    model.authorizationControl = AuthorizationControl.NAMED;
    model.accessRestriction = AccessRestrictionType.PUSH;
    model.verifyCommitter = true;

    // grant user push permission
    user.setRepositoryPermission(model.name, AccessPermission.PUSH);

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

    // clone temp bare repo to working copy
    File local = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-wc");
    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);
    GitBlitSuite.close(clone.call());

    Git git = Git.open(local);

    // force an identity which may or may not match the account's identity
    git.getRepository().getConfig().setString("user", null, "name", displayName);
View Full Code Here

Examples of org.eclipse.jgit.api.CloneCommand

    // fork from original to a temporary bare repo
    File verification = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-committer.git");
    if (verification.exists()) {
      FileUtils.delete(verification, FileUtils.RECURSIVE);
    }
    CloneCommand clone = Git.cloneRepository();
    clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
    clone.setDirectory(verification);
    clone.setBare(true);
    clone.setCloneAllBranches(true);
    clone.setCredentialsProvider(cp);
    GitBlitSuite.close(clone.call());

    // require push permissions and committer verification
    RepositoryModel model = repositories().getRepositoryModel("refchecks/verify-committer.git");
    model.authorizationControl = AuthorizationControl.NAMED;
    model.accessRestriction = AccessRestrictionType.PUSH;
    model.verifyCommitter = true;

    // grant user push permission
    user.setRepositoryPermission(model.name, AccessPermission.PUSH);

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

    // clone temp bare repo to working copy
    File local = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-wc");
    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);
    GitBlitSuite.close(clone.call());

    Git git = Git.open(local);

    // checkout a mergetest branch
    git.checkout().setCreateBranch(true).setName("mergetest").call();
View Full Code Here

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

Examples of org.eclipse.jgit.api.CloneCommand

    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
TOP
Copyright © 2018 www.massapi.com. 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.