Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.RemoteConfig


  private FetchResult fetch(Repository clonedRepo, URIish u)
      throws URISyntaxException,
      JGitInternalException,
      InvalidRemoteException, IOException {
    // 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


    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

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

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

    repo.getConfig().save();

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

  }

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

                            PreBuildMergeOptions mergeOptions = gitSCM.getMergeOptions();

                            if (mergeOptions.doMerge() && buildResult.isBetterOrEqualTo(
                                Result.SUCCESS)) {
                                RemoteConfig remote = mergeOptions.getMergeRemote();
                                listener.getLogger().println(new StringBuilder().append("Pushing result ")
                                    .append(tagName)
                                    .append(" to ")
                                    .append(mergeOptions.getMergeTarget())
                                    .append(" branch of ")
                                    .append(remote.getName())
                                    .append(" repository")
                                    .toString());

                                git.push(remote, "HEAD:" + mergeOptions.getMergeTarget());
//                            } else {
                                //listener.getLogger().println("Pushing result " + buildnumber + " to origin repository");
                                //git.push(null);
                            }

                            return true;
                        }
                    });
                } catch (Throwable e) {
                    listener.error("Failed to push merge to origin repository: " + e.getMessage());
                    build.setResult(Result.FAILURE);
                    mergeResult = false;

                }

                if (!mergeResult) {
                    pushResult = false;
                }
            }
            if (isPushTags()) {
                boolean allTagsResult = true;
                for (final TagToPush t : tagsToPush) {
                    boolean tagResult = true;
                    if (t.getTagName() == null) {
                        listener.getLogger().println("No tag to push defined");
                        tagResult = false;
                    }
                    if (t.getTargetRepoName() == null) {
                        listener.getLogger().println("No target repo to push to defined");
                        tagResult = false;
                    }
                    if (tagResult) {
                        final String tagName = environment.expand(t.getTagName());
                        final String targetRepo = environment.expand(t.getTargetRepoName());

                        try {
                            tagResult = workingDirectory.act(new FileCallable<Boolean>() {
                                private static final long serialVersionUID = 1L;

                                public Boolean invoke(File workspace,
                                                      VirtualChannel channel) throws IOException {

                                    IGitAPI git = new GitAPI(gitExe, new FilePath(workspace),
                                        listener, environment);

                                    RemoteConfig remote = gitSCM.getRepositoryByName(targetRepo);

                                    if (remote == null) {
                                        listener.getLogger()
                                            .println("No repository found for target repo name " + targetRepo);
                                        return false;
                                    }

                                    if (t.isCreateTag()) {
                                        if (git.tagExists(tagName)) {
                                            listener.getLogger()
                                                .println("Tag " + tagName
                                                    + " already exists and Create Tag is specified, so failing.");
                                            return false;
                                        }
                                        git.tag(tagName, "Hudson Git plugin tagging with " + tagName);
                                    } else if (!git.tagExists(tagName)) {
                                        listener.getLogger()
                                            .println("Tag " + tagName
                                                + " does not exist and Create Tag is not specified, so failing.");
                                        return false;
                                    }

                                    listener.getLogger().println("Pushing tag " + tagName + " to repo "
                                        + targetRepo);
                                    git.push(remote, tagName);

                                    return true;
                                }
                            });
                        } catch (Throwable e) {
                            listener.error("Failed to push tag " + tagName + " to " + targetRepo
                                + ": " + e.getMessage());
                            build.setResult(Result.FAILURE);
                            tagResult = false;
                        }
                    }

                    if (!tagResult) {
                        allTagsResult = false;
                    }
                }
                if (!allTagsResult) {
                    pushResult = false;
                }
            }

            if (isPushBranches()) {
                boolean allBranchesResult = true;
                for (final BranchToPush b : branchesToPush) {
                    boolean branchResult = true;
                    if (b.getBranchName() == null) {
                        listener.getLogger().println("No branch to push defined");
                        return false;
                    }
                    if (b.getTargetRepoName() == null) {
                        listener.getLogger().println("No branch repo to push to defined");
                        return false;
                    }
                    final String branchName = environment.expand(b.getBranchName());
                    final String targetRepo = environment.expand(b.getTargetRepoName());

                    if (branchResult) {
                        try {
                            branchResult = workingDirectory.act(new FileCallable<Boolean>() {
                                private static final long serialVersionUID = 1L;

                                public Boolean invoke(File workspace,
                                                      VirtualChannel channel) throws IOException {

                                    IGitAPI git = new GitAPI(gitExe, new FilePath(workspace),
                                        listener, environment);

                                    RemoteConfig remote = gitSCM.getRepositoryByName(targetRepo);

                                    if (remote == null) {
                                        listener.getLogger()
                                            .println("No repository found for target repo name " + targetRepo);
                                        return false;
View Full Code Here

            if (hasHead) {
                List<IndexEntry> submodules = git.getSubmodules("HEAD");

                for (IndexEntry submodule : submodules) {
                    try {
                        RemoteConfig submoduleRemoteRepository
                            = getSubmoduleRepository(git,
                            remoteRepository,
                            submodule.getFile());
                        File subdir = new File(workspace, submodule.getFile());
View Full Code Here

                                                              String mergeTarget,
                                                              List<RemoteConfig> remoteRepositories)
            throws FormException {
            PreBuildMergeOptions mergeOptions = new PreBuildMergeOptions();
            if (doMerge != null && doMerge.trim().length() > 0) {
                RemoteConfig mergeRemote = null;
                String mergeRemoteName = pMergeRemote.trim();
                if (mergeRemoteName.length() == 0) {
                    mergeRemote = remoteRepositories.get(0);
                } else {
                    for (RemoteConfig remote : remoteRepositories) {
View Full Code Here

              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

  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);
    command.setRemote(remote);
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.