Skip to content

Commit 667c06f

Browse files
reckless: handle .git in source locations
1 parent 740ee32 commit 667c06f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tools/reckless

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,14 @@ class InstInfo:
277277
pass
278278
# If unable to search deeper, resort to matching directory name
279279
elif recursion < 1:
280-
if sub.name.lower() == self.name.lower():
280+
if sub.name.lower().removesuffix('.git') == self.name.lower():
281281
# Partial success (can't check for entrypoint)
282282
self.name = sub.name
283283
return sub
284284
return None
285285
sub.populate()
286286

287-
if sub.name.lower() == self.name.lower():
287+
if sub.name.lower().removesuffix('.git') == self.name.lower():
288288
# Directory matches the name we're trying to install, so check
289289
# for entrypoint and dependencies.
290290
for inst in INSTALLERS:
@@ -302,7 +302,7 @@ class InstInfo:
302302
self.entry = found_entry.name
303303
self.deps = found_dep.name
304304
return sub
305-
log.debug(f"missing dependency for {self}")
305+
log.debug(f"{inst.name} installer: missing dependency for {self}")
306306
found_entry = None
307307
for file in sub.contents:
308308
if isinstance(file, SourceDir):
@@ -404,7 +404,7 @@ class Source(Enum):
404404
trailing = Path(source.lower().partition('github.com/')[2]).parts
405405
if len(trailing) < 2:
406406
return None, None
407-
return trailing[0], trailing[1]
407+
return trailing[0], trailing[1].removesuffix('.git')
408408

409409

410410
class SourceDir():
@@ -451,7 +451,7 @@ class SourceDir():
451451
for c in self.contents:
452452
if ftype and not isinstance(c, ftype):
453453
continue
454-
if c.name.lower() == name.lower():
454+
if c.name.lower().removesuffix('.git') == name.lower():
455455
return c
456456
return None
457457

@@ -627,7 +627,7 @@ def populate_github_repo(url: str) -> list:
627627
while '' in repo:
628628
repo.remove('')
629629
repo_name = None
630-
parsed_url = urlparse(url)
630+
parsed_url = urlparse(url.removesuffix('.git'))
631631
if 'github.com' not in parsed_url.netloc:
632632
return None
633633
if len(parsed_url.path.split('/')) < 2:
@@ -1212,7 +1212,7 @@ def _git_update(github_source: InstInfo, local_copy: PosixPath):
12121212
if git.returncode != 0:
12131213
return False
12141214
default_branch = git.stdout.splitlines()[0]
1215-
if default_branch != 'origin/master':
1215+
if default_branch not in ['origin/master', 'origin/main']:
12161216
log.debug(f'UNUSUAL: fetched default branch {default_branch} for '
12171217
f'{github_source.source_loc}')
12181218

@@ -1563,7 +1563,7 @@ def search(plugin_name: str) -> Union[InstInfo, None]:
15631563
for src in RECKLESS_SOURCES:
15641564
# Search repos named after the plugin before collections
15651565
if Source.get_type(src) == Source.GITHUB_REPO:
1566-
if src.split('/')[-1].lower() == plugin_name.lower():
1566+
if src.split('/')[-1].lower().removesuffix('.git') == plugin_name.lower():
15671567
ordered_sources.remove(src)
15681568
ordered_sources.insert(0, src)
15691569
# Check locally before reaching out to remote repositories

0 commit comments

Comments
 (0)