@@ -184,25 +184,49 @@ def validate_repo_state(self, repo):
184
184
if not (repo ["owner" ]["login" ] == "adafruit" and
185
185
repo ["name" ].startswith ("Adafruit_CircuitPython" )):
186
186
return []
187
- full_repo = github .get ("/repos/" + repo ["full_name" ])
188
- if not full_repo .ok :
189
- return [ERROR_UNABLE_PULL_REPO_DETAILS ]
190
- full_repo = full_repo .json ()
187
+
188
+ search_keys = {
189
+ "has_wiki" ,
190
+ "license" ,
191
+ "permissions" ,
192
+ "allow_squash_merge" ,
193
+ "allow_rebase_merge" ,
194
+ }
195
+
196
+ repo_fields = repo .copy ()
197
+
198
+ repo_fields_keys = set (repo_fields .keys ())
199
+ repo_missing_some_keys = search_keys .difference (repo_fields_keys )
200
+
201
+ if repo_missing_some_keys :
202
+ # only call the API if the passed in `repo` doesn't have what
203
+ # we need.
204
+ response = github .get ("/repos/" + repo ["full_name" ])
205
+ if not response .ok :
206
+ return [ERROR_UNABLE_PULL_REPO_DETAILS ]
207
+ repo_fields = response .json ()
208
+
191
209
errors = []
192
- if repo ["has_wiki" ]:
210
+
211
+ if repo_fields .get ("has_wiki" ):
193
212
errors .append (ERROR_WIKI_DISABLED )
194
- if not repo .get ("license" ) and not repo ["name" ] in BUNDLE_IGNORE_LIST :
195
- errors .append (ERROR_MISSING_LICENSE )
196
- if not repo .get ("permissions" , {}).get ("push" ):
213
+
214
+ if (not repo_fields .get ("license" ) and
215
+ not repo ["name" ] in BUNDLE_IGNORE_LIST ):
216
+ errors .append (ERROR_MISSING_LICENSE )
217
+
218
+ if not repo_fields .get ("permissions" , {}).get ("push" ):
197
219
errors .append (ERROR_MISSING_LIBRARIANS )
198
- if (not common_funcs .is_repo_in_bundle (full_repo ["clone_url" ], self .bundle_submodules )
199
- and not repo ["name" ] in BUNDLE_IGNORE_LIST ):
220
+
221
+ repo_in_bundle = common_funcs .is_repo_in_bundle (repo_fields ["clone_url" ],
222
+ self .bundle_submodules )
223
+ if not repo_in_bundle and not repo ["name" ] in BUNDLE_IGNORE_LIST :
200
224
# Don't assume the bundle will bundle itself and possibly
201
225
# other repos.
202
226
errors .append (ERROR_NOT_IN_BUNDLE )
203
- if ( "allow_squash_merge" not in full_repo
204
- or full_repo [ "allow_squash_merge" ]
205
- or full_repo [ "allow_rebase_merge" ] ):
227
+
228
+ if ( repo_fields . get ( "allow_squash_merge" ) or
229
+ repo_fields . get ( "allow_rebase_merge" ) ):
206
230
errors .append (ERROR_ONLY_ALLOW_MERGES )
207
231
return errors
208
232
0 commit comments