Skip to content

Commit 4e172fa

Browse files
reckless: handle lack of cloned source in available cmd
1 parent 5af13c3 commit 4e172fa

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tools/reckless

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def populate_github_repo(url: str) -> list:
707707
return contents
708708

709709

710-
def copy_remote_git_source(github_source: InstInfo):
710+
def copy_remote_git_source(github_source: InstInfo, verbose: bool=True):
711711
"""clone or fetch & checkout a local copy of a remote git repo"""
712712
user, repo = Source.get_github_user_repo(github_source.source_loc)
713713
if not user or not repo:
@@ -726,7 +726,7 @@ def copy_remote_git_source(github_source: InstInfo):
726726
# FIXME: pass LoadedSource and check fetch status
727727
assert _git_update(github_source.source_loc, local_path)
728728
else:
729-
_git_clone(github_source, local_path)
729+
_git_clone(github_source, local_path, verbose)
730730
return SourceDir(local_path, srctype=Source.GIT_LOCAL_CLONE)
731731

732732

@@ -1215,8 +1215,11 @@ def _source_search(name: str, src: LoadedSource) -> Union[InstInfo, None]:
12151215
return None
12161216

12171217

1218-
def _git_clone(src: InstInfo, dest: Union[PosixPath, str]) -> bool:
1219-
log.info(f'cloning {src.srctype} {src}')
1218+
def _git_clone(src: InstInfo, dest: Union[PosixPath, str], verbose: bool=True) -> bool:
1219+
if verbose:
1220+
log.info(f'cloning {src.srctype} {src}')
1221+
else:
1222+
log.debug(f'cloning {src.srctype} {src}')
12201223
if src.srctype == Source.GITHUB_REPO:
12211224
assert 'github.com' in src.source_loc
12221225
source = f"{GITHUB_COM}" + src.source_loc.split("github.com")[-1]
@@ -2091,8 +2094,17 @@ def available_plugins() -> list:
20912094
# It takes too many API calls to query for installable plugins accurately.
20922095
if source.type == Source.GITHUB_REPO and not source.local_clone:
20932096
# FIXME: ignoring non-cloned repos for now.
2094-
log.debug(f'unable to search {source.original_source} without a local clone of the repository.')
2095-
continue
2097+
log.debug(f'cloning {source.original_source} in order to search')
2098+
clone = copy_remote_git_source(InstInfo(None,
2099+
source.original_source,
2100+
source.original_source,
2101+
source_dir=source.content),
2102+
verbose=False)
2103+
if not clone:
2104+
log.warning(f"could not clone github source {source.original_source}")
2105+
continue
2106+
source.local_clone = clone
2107+
source.local_clone.parent_source = source
20962108

20972109
if source.local_clone:
20982110
candidates.extend(find_plugin_candidates(source.local_clone))

0 commit comments

Comments
 (0)