mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 18:31:00 +00:00
Fix loop to be consistent with the others
This commit is contained in:
parent
e4efc039c9
commit
6699770e76
1 changed files with 13 additions and 13 deletions
|
@ -140,21 +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) {
|
||||||
var allOrgs []github.Organization
|
var orgs []github.Organization
|
||||||
var err error
|
var opts = github.ListOptions{}
|
||||||
page := 1
|
opts.Page = 1
|
||||||
for {
|
|
||||||
options := &github.ListOptions{Page: page}
|
for opts.Page > 0 {
|
||||||
orgs, _, err := client.Organizations.List("", options)
|
list, resp, err := client.Organizations.List("", &opts)
|
||||||
if len(orgs) == 0 || err != nil {
|
if err != nil {
|
||||||
break
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, v := range orgs {
|
orgs = append(orgs, list...)
|
||||||
allOrgs = append(allOrgs, v)
|
|
||||||
|
// increment the next page to retrieve
|
||||||
|
opts.Page = resp.NextPage
|
||||||
}
|
}
|
||||||
page++
|
return orgs, nil
|
||||||
}
|
|
||||||
return allOrgs, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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