diff options
author | Kevin Sawicki | 2012-12-09 22:59:26 +0000 |
---|---|---|
committer | Kevin Sawicki | 2012-12-09 22:59:26 +0000 |
commit | eeadbeb7b82ac37f3231eff79c3ffdcb827592b6 (patch) | |
tree | 94f31ba0d99d05bfb342830458510339b1c99d63 | |
parent | 06b147e0e29b39fe0b827c5c7615c795461c7f88 (diff) | |
download | egit-github-eeadbeb7b82ac37f3231eff79c3ffdcb827592b6.tar.gz egit-github-eeadbeb7b82ac37f3231eff79c3ffdcb827592b6.tar.xz egit-github-eeadbeb7b82ac37f3231eff79c3ffdcb827592b6.zip |
Add service support for getting all repositories
Change-Id: Ifda3068d4dba3b24e4c53cf53afba5a5329a90d1
2 files changed, 53 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java index e4a392e3..bb4187b9 100644 --- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java @@ -285,6 +285,32 @@ public class RepositoryServiceTest { } /** + * Page all repositories + * + * @throws IOException + */ + @Test + public void pageAllRepositories() throws IOException { + service.pageAllRepositories().next(); + GitHubRequest request = new GitHubRequest(); + request.setUri(Utils.page("/repositories")); + verify(client).get(request); + } + + /** + * Page all repositories + * + * @throws IOException + */ + @Test + public void pageAllRepositoriesSince() throws IOException { + service.pageAllRepositories(1234).next(); + GitHubRequest request = new GitHubRequest(); + request.setUri(Utils.page("/repositories?since=1234")); + verify(client).get(request); + } + + /** * Get repositories with null user * * @throws IOException diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java index 8d2a2cae..7fc2746d 100644 --- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java @@ -21,6 +21,7 @@ import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_LANGU import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_LEGACY; import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_ORGS; import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS; +import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOSITORIES; import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_SEARCH; import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TAGS; import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TEST; @@ -232,6 +233,32 @@ public class RepositoryService extends GitHubService { } /** + * Page all repositories + * + * @return iterator over pages of repositories + */ + public PageIterator<Repository> pageAllRepositories() { + return pageAllRepositories(-1); + } + + /** + * Page all repositories + * + * @param since + * @return iterator over pages of repositories + */ + public PageIterator<Repository> pageAllRepositories(final long since) { + PagedRequest<Repository> request = createPagedRequest(); + request.setUri(SEGMENT_REPOSITORIES); + if (since > 0) + request.setParams(Collections.singletonMap("since", + Long.toString(since))); + request.setType(new TypeToken<List<Repository>>() { + }.getType()); + return createPageIterator(request); + } + + /** * Get repositories for the given user * * @param user |