mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-25 09:25:49 +00:00
Handle pagination in user repository listing.
This commit is contained in:
parent
63fe7b619c
commit
71ef392cfa
2 changed files with 18 additions and 4 deletions
|
|
@ -201,7 +201,7 @@ func (digest *Digest) fetch(githubClient *github.Client) error {
|
|||
*repo.Name,
|
||||
&github.CommitsListOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: page,
|
||||
Page: page,
|
||||
PerPage: 100,
|
||||
},
|
||||
Author: *digest.User.Login,
|
||||
|
|
|
|||
20
app/repos.go
20
app/repos.go
|
|
@ -208,9 +208,23 @@ type OrgRepos struct {
|
|||
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
|
||||
// repositories the user has access to, not just ones that they own.
|
||||
clientUserRepos, _, err := githubClient.Repositories.List("", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
clientUserRepos := make([]github.Repository, 0)
|
||||
page := 1
|
||||
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{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue