@@ -68,6 +68,7 @@ func GetYamlFiles() []string {
6868 if err != nil {
6969 log .Printf ("Error listing yaml files: %+v" , err )
7070 }
71+
7172 return result
7273}
7374
@@ -119,7 +120,7 @@ func ParseOrg(endPointName string) string {
119120}
120121
121122// GetGithubRepoList returns the list of repositories for a given endpoint
122- func GetGithubRepoList (endPointName string , skipREs []* regexp.Regexp ) ([]string , error ) {
123+ func GetGithubRepoList (endPointName string , skipREs []* regexp.Regexp , onlyREs [] * regexp. Regexp ) ([]string , error ) {
123124 token := os .Getenv ("GITHUB_OAUTH_TOKEN" )
124125 ctx := context .Background ()
125126 ts := oauth2 .StaticTokenSource (
@@ -147,10 +148,13 @@ func GetGithubRepoList(endPointName string, skipREs []*regexp.Regexp) ([]string,
147148 org := ParseOrg (endPointName )
148149 for _ , repo := range repoList {
149150 if repo .Name != nil {
150- name := org + "/" + * (repo .Name )
151- if CheckSkipped (endPointName , skipREs , name ) {
152- repos = append (repos , * (repo .HTMLURL ))
151+ name := "/" + org + "/" + * (repo .Name )
152+ included := CheckIncluded (endPointName , name , skipREs , onlyREs )
153+ if ! included {
154+ continue
153155 }
156+ repos = append (repos , * (repo .HTMLURL ))
157+
154158 }
155159 }
156160 }
@@ -162,15 +166,25 @@ func GetGithubRepoList(endPointName string, skipREs []*regexp.Regexp) ([]string,
162166 return repos , nil
163167}
164168
165- // CheckSkipped verifies whether a particular repo is in the skipped list or not.
166- func CheckSkipped (endPointName string , skipREs []* regexp.Regexp , repo string ) bool {
167- included := true
169+ // CheckIncluded verifies whether a particular repo is in the skipped list or not.
170+ func CheckIncluded (endPointName string , repo string , skipREs []* regexp.Regexp , onlyREs []* regexp.Regexp ) bool {
168171 for _ , skipRE := range skipREs {
169172 if skipRE .MatchString (repo ) {
170- included = false
171173 log .Printf ("%s: skipped %s (%v)\n " , endPointName , repo , skipRE )
174+ return false
175+ }
176+ }
177+ if len (onlyREs ) == 0 {
178+ return true
179+ }
180+ included := false
181+ for _ , onlyRE := range onlyREs {
182+ if onlyRE .MatchString (repo ) {
183+ log .Printf ("%s: included %s (%v)\n " , endPointName , repo , onlyRE )
184+ included = true
172185 break
173186 }
174187 }
188+
175189 return included
176190}
0 commit comments