@@ -850,11 +850,28 @@ def help_alias(targets: list):
850850 sys .exit (1 )
851851
852852
853- def _source_search (name : str , source : str ) -> Union [InstInfo , None ]:
853+ def _source_search (name : str , src : str ) -> Union [InstInfo , None ]:
854854 """Identify source type, retrieve contents, and populate InstInfo
855855 if the relevant contents are found."""
856- root_dir = SourceDir (source )
856+ root_dir = SourceDir (src )
857857 source = InstInfo (name , root_dir .location , None )
858+
859+ # If a local clone of a github source already exists, prefer searching
860+ # that instead of accessing the github API.
861+ if source .srctype == Source .GITHUB_REPO :
862+ # Do we have a local copy already? Use that.
863+ user , repo = Source .get_github_user_repo (src )
864+ assert user
865+ assert repo
866+ local_clone_location = RECKLESS_DIR / '.remote_sources' / user / repo
867+ if local_clone_location .exists ():
868+ # Make sure it's the correct remote source and fetch any updates.
869+ if _git_update (source , local_clone_location ):
870+ logging .debug (f"Using local clone of { src } : "
871+ f"{ local_clone_location } " )
872+ source .source_loc = local_clone_location
873+ source .srctype = Source .GIT_LOCAL_CLONE
874+
858875 if source .get_inst_details ():
859876 return source
860877 return None
0 commit comments