@@ -200,27 +200,14 @@ def get_repo_name(github_url: str) -> str:
200
200
@staticmethod
201
201
def get_github_info (repository_url : str , username : str = "" ,
202
202
token : str = "" ) -> get_github_info_type :
203
+ """This method used to iterate through all resource pages of
204
+ GitHub's /tags API, collect the results, then return a huge
205
+ list with all results.
206
+ Removed because this approach does not scale well and we did
207
+ encounter projects with tens of thousands of tags.
203
208
"""
204
- Query tag infos from GitHub.
205
-
206
- In the good case a list of tags entries (= dictionaries) is returned.
207
- In the bad case a JSON error message is returned.
208
- """
209
- length_per_page = 100
210
- page = 1
211
- tags : List [Dict [str , Any ]] = []
212
- tag_url = "https://api.github.com/repos/" + repository_url + "/tags"
213
- query = "?per_page=%s&page=%s" % (length_per_page , page )
214
- tmp = FindSources .github_request (tag_url + query , username , token )
215
- if not isinstance (tmp , list ):
216
- return tags
217
- tags .extend (tmp )
218
- while len (tmp ) == length_per_page :
219
- page += 1
220
- query = "?per_page=%s&page=%s" % (length_per_page , page )
221
- tmp = FindSources .github_request (tag_url + query , username , token )
222
- tags .extend (tmp )
223
- return tags
209
+ raise NotImplementedError (
210
+ "Removed with introduction of get_matchting_source_tag!" )
224
211
225
212
def _get_github_repo (self , github_ref : str ) -> Dict [str , Any ]:
226
213
"""Fetch GitHub API object identified by @github_ref.
@@ -378,7 +365,7 @@ def find_github_url(self, component: Component, use_language: bool = True) -> st
378
365
if len (name_match ):
379
366
for match in name_match :
380
367
tag_info = self .github_request (match ["tags_url" ], self .github_name , self .github_token )
381
- source_url = self .get_matching_tag ( tag_info , component .version or "" , match ["html_url " ])
368
+ source_url = self .get_matching_source_url ( component .version , match ["tags_url " ])
382
369
if len (name_match ) == 1 :
383
370
return source_url
384
371
elif source_url :
@@ -445,10 +432,7 @@ def find_golang_url(self, component: Component) -> str:
445
432
446
433
if repository_name .startswith ("https://github.com/" ):
447
434
repository_name = repository_name [len ("https://github.com/" ):]
448
- tag_info = self .get_github_info (repository_name , self .github_name , self .github_token )
449
- tag_info_checked = self .check_for_github_error (tag_info )
450
- source_url = self .get_matching_tag (tag_info_checked , component_version ,
451
- repository_name , version_prefix or "" )
435
+ source_url = self .get_matching_source_url (component_version , repository_name , version_prefix )
452
436
453
437
# component["RepositoryUrl"] = repository_name
454
438
return source_url
@@ -468,26 +452,15 @@ def get_github_source_url(self, github_url: str, version: str) -> str:
468
452
469
453
if self .verbose :
470
454
print_text (" repo_name:" , repo_name )
471
-
472
- tag_info = self .get_github_info (repo_name , self .github_name , self .github_token )
473
- tag_info_checked = self .check_for_github_error (tag_info )
474
- return self .get_matching_tag (tag_info_checked , version , github_url )
455
+ return self .get_matching_source_url (version , repo_name )
475
456
476
457
def check_for_github_error (self , tag_info : get_github_info_type ) -> List [Dict [str , Any ]]:
477
- if isinstance (tag_info , list ):
478
- # assume valid answer
479
- return tag_info
480
-
481
- # check for 'rate limit exceeded' message
482
- if "message" in tag_info :
483
- if tag_info ["message" ].startswith ("API rate limit exceeded" ):
484
- print_red ("GitHub API rate limit exceeded - aborting!" )
485
- sys .exit (ResultCode .RESULT_ERROR_ACCESSING_SERVICE )
486
- if tag_info ["message" ].startswith ("Bad credentials" ):
487
- print_red ("Invalid GitHub credential provided - aborting!" )
488
- sys .exit (ResultCode .RESULT_ERROR_ACCESSING_SERVICE )
489
-
490
- return []
458
+ """This method was introduced to check the output of
459
+ get_github_info() for errors.
460
+ Removed, becasue get_github_info was removed.
461
+ """
462
+ raise NotImplementedError (
463
+ "Removed with introduction of get_matchting_source_tag!" )
491
464
492
465
def get_matching_tag (self , tag_info : List [Dict [str , Any ]], version : str , github_url : str ,
493
466
version_prefix : str = "" ) -> str :
0 commit comments