Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.RefSpec


    } catch (URISyntaxException e) {
      return null;
    }
    for (RefSpec refSpec : remoteConfig.getFetchRefSpecs()) {
      if (refSpec.matchSource(mergeRef)) {
        RefSpec expanded = refSpec.expandFromSource(mergeRef);
        return expanded.getDestination();
      }
    }
    return null;
  }
View Full Code Here


    Repository localRepository = createWorkRepository();
    Git localGit = new Git(localRepository);
    StoredConfig config = localRepository.getConfig();
    RemoteConfig rc = new RemoteConfig(config, "origin");
    rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath()));
    rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    rc.update(config);
    config.save();
    FetchResult res = localGit.fetch().setRemote("origin").call();
    assertFalse(res.getTrackingRefUpdates().isEmpty());
    rup = localRepository.updateRef("refs/heads/master");
View Full Code Here

        transport = Transport.open(new URIish(remote));
      transport.setOptionUploadPack(uploadPack);
      configure(transport);
      Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
      if (tags)
        refSpecs.add(new RefSpec(
            "refs/tags/*:refs/remotes/origin/tags/*")); //$NON-NLS-1$
      if (heads)
        refSpecs.add(new RefSpec("refs/heads/*:refs/remotes/origin/*")); //$NON-NLS-1$
      Collection<Ref> refs;
      Map<String, Ref> refmap = new HashMap<String, Ref>();
      fc = transport.openFetch();
      refs = fc.getRefs();
      if (refSpecs.isEmpty())
View Full Code Here

    RemoteConfig config = new RemoteConfig(clonedRepo.getConfig(), remote);
    config.addURI(u);

    final String dst = (bare ? Constants.R_HEADS : Constants.R_REMOTES
        + config.getName() + "/") + "*"; //$NON-NLS-1$//$NON-NLS-2$
    RefSpec refSpec = new RefSpec();
    refSpec = refSpec.setForceUpdate(true);
    refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", dst); //$NON-NLS-1$

    config.addFetchRefSpec(refSpec);
    config.update(clonedRepo.getConfig());

    clonedRepo.getConfig().save();
View Full Code Here

    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$
    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

    // create some refs via commits and tag
    RevCommit commit = remoteGit.commit().setMessage("initial commit").call();
    Ref tagRef = remoteGit.tag().setName("tag").call();

    RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
    git.fetch().setRemote("test").setRefSpecs(spec)
        .call();

    assertEquals(commit.getId(),
        db.resolve(commit.getId().getName() + "^{commit}"));
View Full Code Here

  @Test
  public void fetchShouldAutoFollowTag() throws Exception {
    remoteGit.commit().setMessage("commit").call();
    Ref tagRef = remoteGit.tag().setName("foo").call();

    RefSpec spec = new RefSpec("refs/heads/*:refs/remotes/origin/*");
    git.fetch().setRemote("test").setRefSpecs(spec)
        .setTagOpt(TagOpt.AUTO_FOLLOW).call();

    assertEquals(tagRef.getObjectId(), db.resolve("foo"));
  }
View Full Code Here

      fail("id shouldn't exist yet");
    } catch (MissingObjectException e) {
      // we should get here
    }

    RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
    git1.push().setRemote("test").setRefSpecs(spec)
        .call();

    assertEquals(commit.getId(),
        db2.resolve(commit.getId().getName() + "^{commit}"));
View Full Code Here

    final StoredConfig config = db.getConfig();
    RemoteConfig remoteConfig = new RemoteConfig(config, remote);
    URIish uri = new URIish(db2.getDirectory().toURI().toURL());
    remoteConfig.addURI(uri);
    remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/"
        + remote + "/*"));
    remoteConfig.update(config);
    config.save();


    RevCommit commit2 = git.commit().setMessage("Commit to push").call();

    RefSpec spec = new RefSpec(branch + ":" + branch);
    Iterable<PushResult> resultIterable = git.push().setRemote(remote)
        .setRefSpecs(spec).call();

    PushResult result = resultIterable.iterator().next();
    TrackingRefUpdate trackingRefUpdate = result
View Full Code Here

    final StoredConfig config = git.getRepository().getConfig();
    RemoteConfig remoteConfig = new RemoteConfig(config, "test");
    URIish uri = new URIish(git2.getRepository().getDirectory().toURI()
        .toURL());
    remoteConfig.addURI(uri);
    remoteConfig.addPushRefSpec(new RefSpec("+refs/heads/*:refs/heads/*"));
    remoteConfig.update(config);
    config.save();

    writeTrashFile("f", "content of f");
    git.add().addFilepattern("f").call();
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.