diff options
2 files changed, 72 insertions, 1 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java index 13e0116a..bcb01855 100644 --- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java @@ -160,7 +160,7 @@ public class CommitServiceTest { * @throws IOException */ @Test - public void getComments() throws IOException { + public void getCommitComments() throws IOException { RepositoryId repo = new RepositoryId("o", "n"); service.getComments(repo, "abc"); GitHubRequest request = new GitHubRequest(); @@ -169,6 +169,20 @@ public class CommitServiceTest { } /** + * Get all commit comments + * + * @throws IOException + */ + @Test + public void getAllComments() throws IOException { + RepositoryId repo = new RepositoryId("o", "n"); + service.getComments(repo); + GitHubRequest request = new GitHubRequest(); + request.setUri(Utils.page("/repos/o/n/comments")); + verify(client).get(request); + } + + /** * Get comment comment * * @throws IOException diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/CommitService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/CommitService.java index dc0fa479..7e39d5c3 100644 --- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/CommitService.java +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/CommitService.java @@ -425,4 +425,61 @@ public class CommitService extends GitHubService { return client.post(uri.toString(), params, CommitStatus.class); } + + /** + * Get all comments on all commits in the given repository + * + * @param repository + * @return non-null but possibly empty list of commits + * @throws IOException + */ + public List<CommitComment> getComments(IRepositoryIdProvider repository) + throws IOException { + return getAll(pageComments(repository)); + } + + /** + * Page all comments on all commits in the given repository + * + * @param repository + * @return page iterator over comments + */ + public PageIterator<CommitComment> pageComments( + IRepositoryIdProvider repository) { + return pageComments(repository, PAGE_SIZE); + } + + /** + * Page all comments on all commits in the given repository + * + * @param repository + * @param size + * @return page iterator over comments + */ + public PageIterator<CommitComment> pageComments( + IRepositoryIdProvider repository, int size) { + return pageComments(repository, PAGE_FIRST, size); + } + + /** + * Page all comments on all commits in the given repository + * + * @param repository + * @param start + * @param size + * @return page iterator over comments + */ + public PageIterator<CommitComment> pageComments( + IRepositoryIdProvider repository, int start, int size) { + String id = getId(repository); + + StringBuilder uri = new StringBuilder(SEGMENT_REPOS); + uri.append('/').append(id); + uri.append(SEGMENT_COMMENTS); + PagedRequest<CommitComment> request = createPagedRequest(start, size); + request.setUri(uri); + request.setType(new TypeToken<List<CommitComment>>() { + }.getType()); + return createPageIterator(request); + } } |