mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-17 03:45:13 +00:00
Merge pull request #847 from udzura/master
Getting github orgs more than 30
This commit is contained in:
commit
9aa6c92e90
1 changed files with 15 additions and 2 deletions
|
@ -140,8 +140,21 @@ func GetOrgRepos(client *github.Client, org string) ([]github.Repository, error)
|
||||||
// GetOrgs is a helper function that returns a list of
|
// GetOrgs is a helper function that returns a list of
|
||||||
// all orgs that a user belongs to.
|
// all orgs that a user belongs to.
|
||||||
func GetOrgs(client *github.Client) ([]github.Organization, error) {
|
func GetOrgs(client *github.Client) ([]github.Organization, error) {
|
||||||
orgs, _, err := client.Organizations.List("", nil)
|
var orgs []github.Organization
|
||||||
return orgs, err
|
var opts = github.ListOptions{}
|
||||||
|
opts.Page = 1
|
||||||
|
|
||||||
|
for opts.Page > 0 {
|
||||||
|
list, resp, err := client.Organizations.List("", &opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
orgs = append(orgs, list...)
|
||||||
|
|
||||||
|
// increment the next page to retrieve
|
||||||
|
opts.Page = resp.NextPage
|
||||||
|
}
|
||||||
|
return orgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHook is a heper function that retrieves a hook by
|
// GetHook is a heper function that retrieves a hook by
|
||||||
|
|
Loading…
Reference in a new issue