Exemplo n.º 1
0
  public GitHubDownloader(
      MavenProject project,
      String githubScheme,
      int githubPort,
      boolean includeOpenIssues,
      boolean onlyMilestoneIssues)
      throws MalformedURLException {
    this.includeOpenIssues = includeOpenIssues;
    this.onlyMilestoneIssues = onlyMilestoneIssues;

    URL githubURL = new URL(project.getIssueManagement().getUrl());

    // The githubclient prefers to connect to 'github.com' using the api domain, unlike github
    // enterprise
    // which can connect fine using its domain, so for github.com use empty constructor
    if (githubURL.getHost().equalsIgnoreCase("github.com")) {
      this.client = new GitHubClient();
    } else {
      this.client = new GitHubClient(githubURL.getHost(), githubPort, githubScheme);
    }

    this.githubIssueURL = project.getIssueManagement().getUrl();
    if (!this.githubIssueURL.endsWith("/")) {
      this.githubIssueURL = this.githubIssueURL + "/";
    }

    String urlPath = githubURL.getPath();
    if (urlPath.startsWith("/")) {
      urlPath = urlPath.substring(1);
    }

    if (urlPath.endsWith("/")) {
      urlPath = urlPath.substring(0, urlPath.length() - 2);
    }

    String[] urlPathParts = urlPath.split("/");

    if (urlPathParts.length != 3) {
      throw new MalformedURLException(
          "GitHub issue management URL must look like, " + "[GITHUB_DOMAIN]/[OWNER]/[REPO]/issues");
    }

    this.githubOwner = urlPathParts[0];
    this.githubRepo = urlPathParts[1];
  }
Exemplo n.º 2
0
  private String getUrl() {

    String url = project.getIssueManagement().getUrl();

    if (url.endsWith("/")) {
      url = url.substring(0, url.length() - 1);
    }

    return url;
  }