Handle pagination in user repository listing.

This commit is contained in:
Mihai Parparita 2014-09-21 22:25:06 -07:00
parent 63fe7b619c
commit 71ef392cfa
2 changed files with 18 additions and 4 deletions

View file

@ -201,7 +201,7 @@ func (digest *Digest) fetch(githubClient *github.Client) error {
*repo.Name, *repo.Name,
&github.CommitsListOptions{ &github.CommitsListOptions{
ListOptions: github.ListOptions{ ListOptions: github.ListOptions{
Page: page, Page: page,
PerPage: 100, PerPage: 100,
}, },
Author: *digest.User.Login, Author: *digest.User.Login,

View file

@ -208,9 +208,23 @@ type OrgRepos struct {
func getRepos(c appengine.Context, githubClient *github.Client, account *Account, user *github.User) (*Repos, error) { func getRepos(c appengine.Context, githubClient *github.Client, account *Account, user *github.User) (*Repos, error) {
// The username parameter must be left blank so that we can get all of the // The username parameter must be left blank so that we can get all of the
// repositories the user has access to, not just ones that they own. // repositories the user has access to, not just ones that they own.
clientUserRepos, _, err := githubClient.Repositories.List("", nil) clientUserRepos := make([]github.Repository, 0)
if err != nil { page := 1
return nil, err for {
pageClientUserRepos, response, err := githubClient.Repositories.List("", &github.RepositoryListOptions{
ListOptions: github.ListOptions{
Page: page,
PerPage: 100,
},
})
if err != nil {
return nil, err
}
clientUserRepos = append(clientUserRepos, pageClientUserRepos...)
if response.NextPage == 0 {
break
}
page = response.NextPage
} }
repos := &Repos{} repos := &Repos{}