@@ -18,7 +18,6 @@ import types
1818from typing import Union
1919from urllib .parse import urlparse
2020from urllib .request import urlopen
21- from urllib .error import HTTPError
2221import venv
2322
2423
@@ -258,7 +257,7 @@ class Source(Enum):
258257 REMOTE_GIT_REPO = 3
259258 OTHER_URL = 4
260259 UNKNOWN = 5
261- # Cloned from remote source before searching (rather than github API)
260+ # Cloned from remote source before searching
262261 GIT_LOCAL_CLONE = 6
263262
264263 @classmethod
@@ -302,7 +301,7 @@ class SubmoduleSource:
302301class LoadedSource :
303302 """Allows loading all sources only once per call of reckless. Initialized
304303 with a single line of the reckless .sources file. Keeping state also allows
305- minimizing API calls and refetching repositories."""
304+ minimizing refetching repositories."""
306305 def __init__ (self , source : str ):
307306 self .original_source = source
308307 self .type = Source .get_type (source )
@@ -445,16 +444,12 @@ class InstInfo:
445444 # Set recursion for how many directories deep we should search
446445 depth = 0
447446 if self .srctype in [Source .DIRECTORY , Source .LOCAL_REPO ,
448- Source .GIT_LOCAL_CLONE ]:
447+ Source .GIT_LOCAL_CLONE , Source . REMOTE_GIT_REPO ]:
449448 depth = 5
450- elif self .srctype == Source .REMOTE_GIT_REPO :
451- depth = 1
452449
453450 def search_dir (self , sub : SourceDir , subdir : bool ,
454451 recursion : int ) -> Union [SourceDir , None ]:
455452 assert isinstance (recursion , int )
456- # carveout for archived plugins in lightningd/plugins. Other repos
457- # are only searched by API at the top level.
458453 if recursion == 0 and 'archive' in sub .name .lower ():
459454 pass
460455 # If unable to search deeper, resort to matching directory name
@@ -501,27 +496,7 @@ class InstInfo:
501496 return success
502497 return None
503498
504- try :
505- result = search_dir (self , target , False , depth )
506- # Using the rest API of github.com may result in a
507- # "Error 403: rate limit exceeded" or other access issues.
508- # Fall back to cloning and searching the local copy instead.
509- except HTTPError :
510- result = None
511- if self .srctype == Source .REMOTE_GIT_REPO :
512- # clone source to reckless dir
513- target = copy_remote_git_source (self )
514- if not target :
515- log .warning (f"could not clone github source { self } " )
516- return False
517- log .debug (f"falling back to cloning remote repo { self } " )
518- # Update to reflect use of a local clone
519- self .source_loc = str (target .location )
520- self .srctype = target .srctype
521- result = search_dir (self , target , False , 5 )
522-
523- if not result :
524- return False
499+ result = search_dir (self , target , False , depth )
525500
526501 if result :
527502 if result != target :
@@ -1217,8 +1192,7 @@ def help_alias(targets: list):
12171192
12181193
12191194def _get_local_clone (source : str ) -> Union [Path , None ]:
1220- """Returns the path of a local repository clone of a github source. If one
1221- already exists, prefer searching that to accessing the github API."""
1195+ """Returns the path of a local repository clone of a github source."""
12221196 user , repo = Source .get_github_user_repo (source )
12231197 local_clone_location = RECKLESS_DIR / '.remote_sources' / user / repo
12241198 if local_clone_location .exists ():
@@ -1232,8 +1206,7 @@ def _source_search(name: str, src: LoadedSource) -> Union[InstInfo, None]:
12321206 root_dir = src .content
12331207 source = InstInfo (name , root_dir .location )
12341208
1235- # If a local clone of a github source already exists, prefer searching
1236- # that instead of accessing the github API.
1209+ # Remote git sources require a local clone before searching.
12371210 if src .type == Source .REMOTE_GIT_REPO :
12381211 if src .local_clone :
12391212 if not src .local_clone_fetched :
@@ -2454,18 +2427,11 @@ if __name__ == '__main__':
24542427 LIGHTNING_CONFIG = args .conf
24552428 RECKLESS_CONFIG = load_config (reckless_dir = str (RECKLESS_DIR ),
24562429 network = NETWORK )
2457- API_GITHUB_COM = 'https://api.github.com'
24582430 GITHUB_COM = 'https://github.com'
24592431 # Used for blackbox testing to avoid hitting github servers
2460- if 'REDIR_GITHUB_API' in os .environ :
2461- API_GITHUB_COM = os .environ ['REDIR_GITHUB_API' ]
24622432 if 'REDIR_GITHUB' in os .environ :
24632433 GITHUB_COM = os .environ ['REDIR_GITHUB' ]
24642434
2465- GITHUB_API_FALLBACK = False
2466- if 'GITHUB_API_FALLBACK' in os .environ :
2467- GITHUB_API_FALLBACK = os .environ ['GITHUB_API_FALLBACK' ]
2468-
24692435 RECKLESS_SOURCES = load_sources ()
24702436 if 'targets' in args : # and len(args.targets) > 0:
24712437 if args .func .__name__ == 'help_alias' :
0 commit comments