Exemplo 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");
    }
  }
Exemplo n.º 2
0
  private String putChangelogDiffsIntoFile(
      IGitAPI git, String branchName, String revFrom, String revTo) throws IOException {
    ByteArrayOutputStream fos = new ByteArrayOutputStream();
    // fos.write("<data><![CDATA[".getBytes());
    String changeset =
        "Changes in branch " + branchName + ", between " + revFrom + " and " + revTo + "\n";
    fos.write(changeset.getBytes());

    git.changelog(revFrom, revTo, fos);
    // fos.write("]]></data>".getBytes());
    fos.close();
    return fos.toString();
  }