11package organizations
22
33import (
4+ "fmt"
45 "github.com/google/go-github/v27/github"
56 "github.com/whosonfirst/go-whosonfirst-github/util"
67 "log"
@@ -61,6 +62,13 @@ func ListReposWithCallback(org string, opts *ListOptions, cb func(repo *github.R
6162
6263 for {
6364
65+ select {
66+ case <- ctx .Done ():
67+ break
68+ default :
69+ // pass
70+ }
71+
6472 possible , resp , err := client .Repositories .ListByOrg (ctx , org , gh_opts )
6573
6674 if err != nil {
@@ -69,30 +77,37 @@ func ListReposWithCallback(org string, opts *ListOptions, cb func(repo *github.R
6977
7078 for _ , r := range possible {
7179
72- has_prefix := false
73- is_excluded := false
80+ if len (opts .Prefix ) > 0 {
81+
82+ has_prefix := false
7483
75- for _ , prefix := range opts .Prefix {
76- if strings .HasPrefix (* r .Name , prefix ) {
77- has_prefix = true
78- break
84+ for _ , prefix := range opts .Prefix {
85+ if strings .HasPrefix (* r .Name , prefix ) {
86+ has_prefix = true
87+ break
88+ }
7989 }
80- }
8190
82- if ! has_prefix {
83- continue
91+ if ! has_prefix {
92+ continue
93+ }
8494 }
8595
86- for _ , prefix := range opts .Exclude {
96+ if len (opts .Exclude ) > 0 {
97+
98+ is_excluded := false
8799
88- if strings .HasPrefix (* r .Name , prefix ) {
89- is_excluded = true
90- break
100+ for _ , prefix := range opts .Exclude {
101+
102+ if strings .HasPrefix (* r .Name , prefix ) {
103+ is_excluded = true
104+ break
105+ }
91106 }
92- }
93107
94- if is_excluded {
95- continue
108+ if is_excluded {
109+ continue
110+ }
96111 }
97112
98113 if opts .Forked && ! * r .Fork {
@@ -117,7 +132,7 @@ func ListReposWithCallback(org string, opts *ListOptions, cb func(repo *github.R
117132 err := cb (r )
118133
119134 if err != nil {
120- return err
135+ return fmt . Errorf ( "Failed to invoke callback for '%v', %w" , r , err )
121136 }
122137
123138 }
0 commit comments