public GitHubDownloader()

in src/main/java/org/apache/maven/plugins/changes/github/GitHubDownloader.java [77:117]


    public GitHubDownloader(MavenProject project, boolean includeOpenIssues, boolean onlyMilestoneIssues)
            throws IOException {
        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 GitHubBuilder();
        } else {
            this.client = new GitHubBuilder()
                    .withEndpoint(githubURL.getProtocol() + "://" + githubURL.getHost()
                            + (githubURL.getPort() == -1 ? "" : ":" + githubURL.getPort()));
        }

        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];
    }