diff options
author | Kevin Sawicki | 2012-11-28 21:45:05 +0000 |
---|---|---|
committer | Kevin Sawicki | 2012-11-28 21:45:05 +0000 |
commit | 48c9af4adfc9ab379615282b3005a72a09eb402d (patch) | |
tree | 74fa53f30d343568da40115a10899c3d681008e2 | |
parent | 4a91e785aed6184e8d65e9f18316862314291228 (diff) | |
download | egit-github-48c9af4adfc9ab379615282b3005a72a09eb402d.tar.gz egit-github-48c9af4adfc9ab379615282b3005a72a09eb402d.tar.xz egit-github-48c9af4adfc9ab379615282b3005a72a09eb402d.zip |
Support requesting all commit comments
Change-Id: Iad6d20e74453a2d2b751d857cb620670a35e296b
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); + } } |