Skip to content

Commit

Permalink
Merge pull request #136 from rtyley/page-team-repositories
Browse files Browse the repository at this point in the history
Add paging support for Team's Repositories
  • Loading branch information
kohsuke committed Dec 19, 2014
2 parents e15f7a5 + e7262b8 commit 5a70835
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/java/org/kohsuke/github/GHTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,27 @@ public boolean hasMember(GHUser user) {
}

public Map<String,GHRepository> getRepositories() throws IOException {
GHRepository[] repos = org.root.retrieve().to(api("/repos"), GHRepository[].class);
Map<String,GHRepository> m = new TreeMap<String, GHRepository>();
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<GHRepository> listRepositories() {
return new PagedIterable<GHRepository>() {
public PagedIterator<GHRepository> iterator() {
return new PagedIterator<GHRepository>(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.
*
Expand Down

0 comments on commit 5a70835

Please sign in to comment.