mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +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,
|
*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,
|
||||||
|
|
|
||||||
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) {
|
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{}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue