Examples of RemoteConfig


Examples of org.eclipse.jgit.transport.RemoteConfig

    ArrayList<PushResult> pushResults = new ArrayList<PushResult>(3);

    try {
      if (refSpecs.isEmpty()) {
        RemoteConfig config = new RemoteConfig(repo.getConfig(),
            getRemote());
        refSpecs.addAll(config.getPushRefSpecs());
      }
      if (refSpecs.isEmpty()) {
        Ref head = repo.getRef(Constants.HEAD);
        if (head != null && head.isSymbolic())
          refSpecs.add(new RefSpec(head.getLeaf().getName()));
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

    Repository remoteRepository = createWorkRepository();
    remoteGit = new Git(remoteRepository);

    // setup the first repository to fetch from the second repository
    final StoredConfig config = db.getConfig();
    RemoteConfig remoteConfig = new RemoteConfig(config, "test");
    URIish uri = new URIish(remoteRepository.getDirectory().toURI().toURL());
    remoteConfig.addURI(uri);
    remoteConfig.update(config);
    config.save();

    remoteGit.commit().setMessage("initial commit").call();
    remoteGit.tag().setName("tag").call();
    remoteGit.checkout().setName("other").setCreateBranch(true).call();
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

    addRemote(remotesLocation, remoteName, remoteUri, fetchRefSpec, pushUri, pushRefSpec);

    Repository db2 = FileRepositoryBuilder.create(GitUtils.getGitDir(new Path(toRelativeURI(clonePath.toString()))));
    toClose.add(db2);
    StoredConfig config = db2.getConfig();
    RemoteConfig rc = new RemoteConfig(config, remoteName);

    assertNotNull(rc);
    // main uri
    assertEquals(1, rc.getURIs().size());
    assertEquals(new URIish(remoteUri).toString(), rc.getURIs().get(0).toString());
    // fetchRefSpec
    assertEquals(1, rc.getFetchRefSpecs().size());
    assertEquals(new RefSpec(fetchRefSpec), rc.getFetchRefSpecs().get(0));
    // pushUri
    assertEquals(1, rc.getPushURIs().size());
    assertEquals(new URIish(pushUri).toString(), rc.getPushURIs().get(0).toString());
    // pushRefSpec
    assertEquals(1, rc.getPushRefSpecs().size());
    assertEquals(new RefSpec(pushRefSpec), rc.getPushRefSpecs().get(0));
  }
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

    Repository db = null;
    try {
      db = FileRepositoryBuilder.create(gitDir);
      StoredConfig config = db.getConfig();

      RemoteConfig rc = new RemoteConfig(config, remoteName);
      rc.addURI(new URIish(remoteURI));
      // FetchRefSpec is required, but default version can be generated
      // if it isn't provided
      if (fetchRefSpec == null || fetchRefSpec.isEmpty()) {
        fetchRefSpec = String.format("+refs/heads/*:refs/remotes/%s/*", remoteName); //$NON-NLS-1$
      }
      rc.addFetchRefSpec(new RefSpec(fetchRefSpec));
      // pushURI is optional
      if (remotePushURI != null && !remotePushURI.isEmpty())
        rc.addPushURI(new URIish(remotePushURI));
      // PushRefSpec is optional
      if (pushRefSpec != null && !pushRefSpec.isEmpty())
        rc.addPushRefSpec(new RefSpec(pushRefSpec));

      rc.update(config);
      config.save();

      Remote remote = new Remote(cloneLocation, db, remoteName);
      JSONObject result = new JSONObject();
      result.put(ProtocolConstants.KEY_LOCATION, remote.getLocation());
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

            map.put(GitConstants.KEY_COOKIE, cookie.getName() + "=" + cookie.getValue());
            ((TransportHttp) t).setAdditionalHeaders(map);
          }
        }
      });
      RemoteConfig remoteConfig = new RemoteConfig(git.getRepository().getConfig(), remote);
      credentials.setUri(remoteConfig.getURIs().get(0));
      pushCommand.setCredentialsProvider(credentials);

      boolean pushToGerrit = branch.startsWith("for/");
      RefSpec spec = new RefSpec(srcRef + ':' + (pushToGerrit ? "refs/" : Constants.R_HEADS) + branch);
      pushCommand.setRemote(remote).setRefSpecs(spec);
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

  private JSONArray getRemotes() throws URISyntaxException, JSONException, IOException, CoreException {
    String branchName = Repository.shortenRefName(ref.getName());
    JSONArray result = new JSONArray();
    String remoteName = getConfig().getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REMOTE);
    if (remoteName != null) {
      RemoteConfig remoteConfig = new RemoteConfig(getConfig(), remoteName);
      if (!remoteConfig.getFetchRefSpecs().isEmpty()) {
        Remote remote = new Remote(cloneLocation, db, remoteName);
        remote.setNewBranch(branchName);
        result.put(remote.toJSON());
      }
    } else {
      List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(getConfig());
      for (RemoteConfig remoteConfig : remoteConfigs) {
        if (!remoteConfig.getFetchRefSpecs().isEmpty()) {
          Remote r = new Remote(cloneLocation, db, remoteConfig.getName());
          r.setNewBranch(branchName);
          if (db.resolve(Constants.R_REMOTES + remoteConfig.getName() + "/" + branchName) != null) { //$NON-NLS-1$
            // it's an existing branch, not a new one, use it as filter
            return new JSONArray().put(r.toJSON());
          }
          result.put(r.toJSON());
        }
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

      db = getRepository();
      Git git = new Git(db);
      FetchCommand fc = git.fetch();
      fc.setProgressMonitor(gitMonitor);

      RemoteConfig remoteConfig = new RemoteConfig(git.getRepository().getConfig(), remote);
      credentials.setUri(remoteConfig.getURIs().get(0));
      if (this.cookie != null) {
        fc.setTransportConfigCallback(new TransportConfigCallback() {
          @Override
          public void configure(Transport t) {
            if (t instanceof TransportHttp && cookie != null) {
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

    doCheckout(branch);
  }

  private void saveRemote(final URIish uri) throws URISyntaxException,
      IOException {
    final RemoteConfig rc = new RemoteConfig(dst.getConfig(), remoteName);
    rc.addURI(uri);
    rc.addFetchRefSpec(new RefSpec().setForceUpdate(true)
        .setSourceDestination(Constants.R_HEADS + "*",
            Constants.R_REMOTES + remoteName + "/*"));
    rc.update(dst.getConfig());
    dst.getConfig().save();
  }
 
View Full Code Here

Examples of org.eclipse.jgit.transport.RemoteConfig

  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();
    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(clonedRepo.getConfig());

    clonedRepo.getConfig().save();

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

Examples of org.eclipse.jgit.transport.RemoteConfig

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

            RemoteConfig remoteConfig;
            try {
              remoteConfig = new RemoteConfig(getConfig(),
                  "origin");
            } 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
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.