Skip to content

Commit

Permalink
Add paging support for Team's Repositories
Browse files Browse the repository at this point in the history
The team repositories endpoint does do paging, so gotta support that.
  • Loading branch information
rtyley committed Nov 6, 2014
1 parent af3099c commit e7262b8
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 e7262b8

Please sign in to comment.