From e7262b8fbee1175d6a59bb2ba9f98b2e56d357d2 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Thu, 6 Nov 2014 09:40:37 +0000 Subject: [PATCH] Add paging support for Team's Repositories The team repositories endpoint does do paging, so gotta support that. --- src/main/java/org/kohsuke/github/GHTeam.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHTeam.java b/src/main/java/org/kohsuke/github/GHTeam.java index 56dafe3978..b8c6b1cb6f 100644 --- a/src/main/java/org/kohsuke/github/GHTeam.java +++ b/src/main/java/org/kohsuke/github/GHTeam.java @@ -68,14 +68,27 @@ public boolean hasMember(GHUser user) { } public Map getRepositories() throws IOException { - GHRepository[] repos = org.root.retrieve().to(api("/repos"), GHRepository[].class); Map m = new TreeMap(); - for (GHRepository r : repos) { - m.put(r.getName(),r.wrap(org.root)); + for (GHRepository r : listRepositories()) { + m.put(r.getName(), r); } return m; } + public PagedIterable listRepositories() { + return new PagedIterable() { + public PagedIterator iterator() { + return new PagedIterator(org.root.retrieve().asIterator(api("/repos"), GHRepository[].class)) { + @Override + protected void wrapUp(GHRepository[] page) { + for (GHRepository r : page) + r.wrap(org.root); + } + }; + } + }; + } + /** * Adds a member to the team. *