Esempio n. 1
0
  /**
   * Fetch information from a particular remote repository. Attempt to fetch from submodules, if
   * they exist in the local WC
   *
   * @param git
   * @param listener
   * @param remoteRepository
   * @throws
   */
  private void fetchFrom(
      IGitAPI git, File workspace, TaskListener listener, RemoteConfig remoteRepository) {
    try {
      git.fetch(remoteRepository);

      List<IndexEntry> submodules = new GitUtils(listener, git).getSubmodules("HEAD");

      for (IndexEntry submodule : submodules) {
        try {
          RemoteConfig submoduleRemoteRepository =
              getSubmoduleRepository(remoteRepository, submodule.getFile());

          File subdir = new File(workspace, submodule.getFile());
          IGitAPI subGit =
              new GitAPI(git.getGitExe(), new FilePath(subdir), listener, git.getEnvironment());

          subGit.fetch(submoduleRemoteRepository);
        } catch (Exception ex) {
          listener.error(
              "Problem fetching from "
                  + remoteRepository.getName()
                  + " - could be unavailable. Continuing anyway");
        }
      }
    } catch (GitException ex) {
      listener.error(
          "Problem fetching from "
              + remoteRepository.getName()
              + " / "
              + remoteRepository.getName()
              + " - could be unavailable. Continuing anyway");
    }
  }