Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.RefSpec


    return command.call();
  }

  private List<RefSpec> calculateRefSpecs(final String dst) {
    RefSpec wcrs = new RefSpec();
    wcrs = wcrs.setForceUpdate(true);
    wcrs = wcrs.setSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$
    List<RefSpec> specs = new ArrayList<RefSpec>();
    if (cloneAllBranches)
      specs.add(wcrs);
    else if (branchesToClone != null
        && branchesToClone.size() > 0) {
      for (final String selectedRef : branchesToClone)
        if (wcrs.matchSource(selectedRef))
          specs.add(wcrs.expandFromSource(selectedRef));
    }
    return specs;
  }
View Full Code Here


   {
      FetchCommand fetch = git.fetch();
      fetch.setCheckFetchedObjects(fsck);
      fetch.setRemoveDeletedRefs(prune);
      if (refSpec != null)
         fetch.setRefSpecs(new RefSpec(refSpec));
      if (timeout >= 0)
         fetch.setTimeout(timeout);
      fetch.setDryRun(dryRun);
      fetch.setRemote(remote);
      fetch.setThin(thin);
View Full Code Here

      clone.setDirectory(folder);
      Git git = clone.call();

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

      git.getRepository().close();
    } catch (Exception e) {
      throw new GitBlitException(e);
View Full Code Here

      Repository repository, RefSpec... refSpecs) throws Exception {
    Git git = new Git(repository);
    FetchCommand fetch = git.fetch();
    List<RefSpec> specs = new ArrayList<RefSpec>();
    if (refSpecs == null || refSpecs.length == 0) {
      specs.add(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
      specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
      specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));
    } else {
      specs.addAll(Arrays.asList(refSpecs));
    }
    if (credentialsProvider != null) {
      fetch.setCredentialsProvider(credentialsProvider);
View Full Code Here

      int invalidSpecs = 0;
      int repairedSpecs = 0;
      List<String> specs = new ArrayList<String>();
      for (String spec : rc.getStringList("remote", name, "fetch")) {
        try {
          RefSpec rs = new RefSpec(spec);
          // valid spec
          specs.add(spec);
        } catch (IllegalArgumentException e) {
          // invalid spec
          invalidSpecs++;
View Full Code Here

      }
    }

    // create a local branch and push the new branch back to the origin
    git.branchCreate().setName("protectme").call();
    RefSpec refSpec = new RefSpec("refs/heads/protectme:refs/heads/protectme");
    results = git.push().setCredentialsProvider(cp).setRefSpecs(refSpec).setRemote("origin").call();
    for (PushResult result : results) {
      RemoteRefUpdate ref = result.getRemoteUpdate("refs/heads/protectme");
      Status status = ref.getStatus();
      if (Status.OK.equals(expectedCreate)) {
        assertTrue("User failed to push creation?! " + status.name(), status.equals(expectedCreate));
      } else {
        // close serving repository
        GitBlitSuite.close(refChecks);

        assertTrue("User was able to push ref creation! " + status.name(), status.equals(expectedCreate));
        GitBlitSuite.close(git);
        // skip delete test
        return;
      }
    }

    // delete the branch locally
    git.branchDelete().setBranchNames("protectme").call();

    // push a delete ref command
    refSpec = new RefSpec(":refs/heads/protectme");
    results = git.push().setCredentialsProvider(cp).setRefSpecs(refSpec).setRemote("origin").call();
    for (PushResult result : results) {
      RemoteRefUpdate ref = result.getRemoteUpdate("refs/heads/protectme");
      Status status = ref.getStatus();
      if (Status.OK.equals(expectedDelete)) {
View Full Code Here

    RemoteConfig config = new RemoteConfig(targetConfig, "origin");

    config
        .addURI(new URIish(source.getRepository().getWorkTree()
            .getAbsolutePath()));
    config.addFetchRefSpec(new RefSpec(
        "+refs/heads/*:refs/remotes/origin/*"));
    config.update(targetConfig);
    targetConfig.save();

    targetFile = new File(dbTarget.getWorkTree(), "SomeFile.txt");
View Full Code Here

    RemoteConfig config = new RemoteConfig(targetConfig, "origin");

    config
        .addURI(new URIish(source.getRepository().getWorkTree()
            .getAbsolutePath()));
    config.addFetchRefSpec(new RefSpec(
        "+refs/heads/*:refs/remotes/origin/*"));
    config.update(targetConfig);
    targetConfig.save();

    targetFile = new File(dbTarget.getWorkTree(), "SomeFile.txt");
View Full Code Here

    super(parser, option, setter);
  }

  @Override
  public int parseArguments(final Parameters params) throws CmdLineException {
    setter.addValue(new RefSpec(params.getParameter(0)));
    return 1;
  }
View Full Code Here

                    ConfigConstants.CONFIG_KEY_MERGE);
            List<RefSpec> fetchRefSpecs = remoteConfig
                .getFetchRefSpecs();
            for (RefSpec refSpec : fetchRefSpecs) {
              if (refSpec.matchSource(remoteBranchName)) {
                RefSpec expandFromSource = refSpec
                    .expandFromSource(remoteBranchName);
                name = expandFromSource.getDestination();
                break;
              }
            }
            if (name == null)
              throw new RevisionSyntaxException(revstr);
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.RefSpec

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.