Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/spotify/github/v3/clients/GitHubClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.spotify.github.v3.comment.CommentReaction;
import com.spotify.github.v3.exceptions.ReadOnlyRepositoryException;
import com.spotify.github.v3.exceptions.RequestNotOkException;
import com.spotify.github.v3.git.FileItem;
import com.spotify.github.v3.git.Reference;
import com.spotify.github.v3.orgs.TeamInvitation;
import com.spotify.github.v3.prs.PullRequestItem;
Expand Down Expand Up @@ -108,6 +109,9 @@ public class GitHubClient {
static final TypeReference<List<TeamInvitation>> LIST_PENDING_TEAM_INVITATIONS =
new TypeReference<>() {};

static final TypeReference<List<FileItem>> LIST_FILE_ITEMS =
new TypeReference<>() {};

private static final String GET_ACCESS_TOKEN_URL = "app/installations/%s/access_tokens";

private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
Expand Down
40 changes: 23 additions & 17 deletions src/main/java/com/spotify/github/v3/clients/PullRequestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,18 @@

package com.spotify.github.v3.clients;

import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.invoke.MethodHandles;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import static java.util.Objects.isNull;
import java.util.concurrent.CompletableFuture;

import javax.ws.rs.core.HttpHeaders;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.spotify.github.async.AsyncPage;
import static com.spotify.github.v3.clients.GitHubClient.IGNORE_RESPONSE_CONSUMER;
import static com.spotify.github.v3.clients.GitHubClient.LIST_COMMIT_TYPE_REFERENCE;
import static com.spotify.github.v3.clients.GitHubClient.LIST_FILE_ITEMS;
import static com.spotify.github.v3.clients.GitHubClient.LIST_PR_TYPE_REFERENCE;
import static com.spotify.github.v3.clients.GitHubClient.LIST_REVIEW_REQUEST_TYPE_REFERENCE;
import static com.spotify.github.v3.clients.GitHubClient.LIST_REVIEW_TYPE_REFERENCE;
import static java.util.Objects.isNull;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.spotify.github.async.AsyncPage;
import com.spotify.github.v3.git.FileItem;
import com.spotify.github.v3.prs.Comment;
import com.spotify.github.v3.prs.MergeParameters;
import com.spotify.github.v3.prs.PullRequest;
Expand All @@ -54,6 +44,16 @@
import com.spotify.github.v3.prs.requests.PullRequestParameters;
import com.spotify.github.v3.prs.requests.PullRequestUpdate;
import com.spotify.github.v3.repos.CommitItem;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.invoke.MethodHandles;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.ws.rs.core.HttpHeaders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Pull call API client */
public class PullRequestClient {
Expand All @@ -63,6 +63,7 @@ public class PullRequestClient {
private static final String PR_NUMBER_TEMPLATE = "/repos/%s/%s/pulls/%s";
private static final String PR_COMMITS_TEMPLATE = "/repos/%s/%s/pulls/%s/commits";
private static final String PR_REVIEWS_TEMPLATE = "/repos/%s/%s/pulls/%s/reviews";
private static final String PR_CHANGED_FILES_TEMPLATE = "/repos/%s/%s/pulls/%s/files";
private static final String PR_REVIEW_REQUESTS_TEMPLATE =
"/repos/%s/%s/pulls/%s/requested_reviewers";
private static final String PR_COMMENT_REPLIES_TEMPLATE =
Expand Down Expand Up @@ -449,6 +450,11 @@ public CompletableFuture<Reader> diff(final long prNumber) {
});
}

public Iterator<AsyncPage<FileItem>> changedFiles(final long prNumber) {
final String path = String.format(PR_CHANGED_FILES_TEMPLATE, owner, repo, prNumber);
return new GithubPageIterator<>(new GithubPage<>(github, path, LIST_FILE_ITEMS));
}

/**
* List pull requests using given parameters.
*
Expand Down
Loading