From 654249b48747922b26ab4c8d193ea73754ccc4a5 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Mon, 1 Jan 2018 11:58:01 -0500 Subject: [PATCH] add affiliation Signed-off-by: Jess Frazelle --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 3c0bb2a..cfe2c25 100644 --- a/main.go +++ b/main.go @@ -151,14 +151,19 @@ func main() { page := 1 perPage := 100 + affiliation := "owner,collaborator" + if len(orgs) > 0 { + affiliation += ",organization_member" + } logrus.Debugf("Getting repositories...") - if err := getRepositories(ctx, client, page, perPage); err != nil { + if err := getRepositories(ctx, client, page, perPage, affiliation); err != nil { logrus.Fatal(err) } } -func getRepositories(ctx context.Context, client *github.Client, page, perPage int) error { +func getRepositories(ctx context.Context, client *github.Client, page, perPage int, affiliation string) error { opt := &github.RepositoryListOptions{ + Affiliation: affiliation, ListOptions: github.ListOptions{ Page: page, PerPage: perPage, @@ -182,7 +187,7 @@ func getRepositories(ctx context.Context, client *github.Client, page, perPage i } page = resp.NextPage - return getRepositories(ctx, client, page, perPage) + return getRepositories(ctx, client, page, perPage, affiliation) } // handleRepo will return nil error if the user does not have access to something.