Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.RemoteConfig


  private FetchResult fetch(Repository repo, URIish u)
      throws URISyntaxException,
      JGitInternalException,
      InvalidRemoteException, IOException {
    // create the remote config and save it
    RemoteConfig config = new RemoteConfig(repo.getConfig(), remote);
    config.addURI(u);

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

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

    repo.getConfig().save();

    // run the fetch command
    FetchCommand command = new FetchCommand(repo);
View Full Code Here


          JGitUtils.repairFetchSpecs(repository);
        }

        // find the first mirror remote - there should only be one
        StoredConfig rc = repository.getConfig();
        RemoteConfig mirror = null;
        List<RemoteConfig> configs = RemoteConfig.getAllRemoteConfigs(rc);
        for (RemoteConfig config : configs) {
          if (config.isMirror()) {
            mirror = config;
            break;
          }
        }

        if (mirror == null) {
          // repository does not have a mirror remote
          logger.debug("mirror is skipping {} no mirror remote found", repositoryName);
          continue;
        }

        logger.debug("checking {} remote {} for ref updates", repositoryName, mirror.getName());
        final boolean testing = false;
        Git git = new Git(repository);
        FetchResult result = git.fetch().setRemote(mirror.getName()).setDryRun(testing).call();
        Collection<TrackingRefUpdate> refUpdates = result.getTrackingRefUpdates();
        if (refUpdates.size() > 0) {
          ReceiveCommand ticketBranchCmd = null;
          for (TrackingRefUpdate ru : refUpdates) {
            StringBuilder sb = new StringBuilder();
View Full Code Here

   * @return true if exists, false otherwise
   * @throws URISyntaxException
   */
  protected static boolean hasRemote(final Repository repository,
      final String remote) throws URISyntaxException {
    final RemoteConfig config = new RemoteConfig(repository.getConfig(),
        remote);
    return !config.getURIs().isEmpty() || !config.getPushURIs().isEmpty();
  }
View Full Code Here

    Repository repo = new FileRepository(testRepo);
    RefUpdate originMaster = repo.updateRef(Constants.R_REMOTES
        + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER);
    originMaster.setNewObjectId(commit1);
    originMaster.forceUpdate();
    RemoteConfig config = new RemoteConfig(repo.getConfig(),
        Constants.DEFAULT_REMOTE_NAME);
    config.addURI(new URIish(repo2.toURI().toString()));
    config.update(repo.getConfig());
    Collection<RefDiff> diffs = RepositoryUtils.diffOriginRefs(repo);
    assertNotNull(diffs);
    assertFalse(diffs.isEmpty());
    assertNotNull(diffs.iterator().next().getLocal());
    assertNotNull(diffs.iterator().next().getRemote());
View Full Code Here

    // configure the target repo to connect to the source via "origin"
    StoredConfig targetConfig = dbTarget.getConfig();
    targetConfig.setString("branch", "master", "remote", "origin");
    targetConfig
        .setString("branch", "master", "merge", "refs/heads/master");
    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");
    // make sure we have the same content
    target.pull().call();
View Full Code Here

    // configure the target repo to connect to the source via "origin"
    StoredConfig targetConfig = dbTarget.getConfig();
    targetConfig.setString("branch", "master", "remote", "origin");
    targetConfig
        .setString("branch", "master", "merge", "refs/heads/master");
    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");
    // make sure we have the same content
    target.pull().call();
View Full Code Here

              return null;
            if (ref.isSymbolic())
              ref = ref.getLeaf();
            name = ref.getName();

            RemoteConfig remoteConfig;
            try {
              remoteConfig = new RemoteConfig(getConfig(),
                  "origin"); //$NON-NLS-1$
            } catch (URISyntaxException e) {
              throw new RevisionSyntaxException(revstr);
            }
            String remoteBranchName = getConfig()
                .getString(
                    ConfigConstants.CONFIG_BRANCH_SECTION,
                Repository.shortenRefName(ref.getName()),
                    ConfigConstants.CONFIG_KEY_MERGE);
            List<RefSpec> fetchRefSpecs = remoteConfig
                .getFetchRefSpecs();
            for (RefSpec refSpec : fetchRefSpecs) {
              if (refSpec.matchSource(remoteBranchName)) {
                RefSpec expandFromSource = refSpec
                    .expandFromSource(remoteBranchName);
View Full Code Here

   *            merge Ref of the local branch tracking the remote tracking
   *            branch
   * @return full remote tracking branch name or null
   */
  private String findRemoteTrackingBranch(String remote, String mergeRef) {
    RemoteConfig remoteConfig;
    try {
      remoteConfig = new RemoteConfig(config, remote);
    } catch (URISyntaxException e) {
      return null;
    }
    for (RefSpec refSpec : remoteConfig.getFetchRefSpecs()) {
      if (refSpec.matchSource(mergeRef)) {
        RefSpec expanded = refSpec.expandFromSource(mergeRef);
        return expanded.getDestination();
      }
    }
View Full Code Here

  private FetchResult fetch(Repository clonedRepo, URIish u)
      throws URISyntaxException,
      org.eclipse.jgit.api.errors.TransportException, IOException,
      GitAPIException {
    // create the remote config and save it
    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();

    // run the fetch command
    FetchCommand command = new FetchCommand(clonedRepo);
View Full Code Here

    rup.forceUpdate();

    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");
    rup.setNewObjectId(initialCommit.getId());
View Full Code Here

TOP

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

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.