Skip to content

Commit 5377d3d

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: clean up _source.py — remove redundant rstrip and normalize variable usage
In parse_github_source, subpath already has trailing slashes stripped by strip("/"), making the subsequent rstrip("/") a no-op. In _fetch_named_ralph, extract the ralph_name alias at the top so both early-return paths and the search path use it consistently instead of mixing parsed.name and ralph_name. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent fe4cb5e commit 5377d3d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/ralphify/_source.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def parse_github_source(source: str) -> ParsedSource:
8080

8181
repo_url = f"https://github.com/{owner}/{repo}.git"
8282
subpath = rest.strip("/") if rest else None
83-
name = subpath.rstrip("/").rsplit("/", 1)[-1] if subpath else repo
83+
name = subpath.rsplit("/", 1)[-1] if subpath else repo
8484
handle = f"{owner}/{repo}/{subpath}" if subpath else f"{owner}/{repo}"
8585

8686
return ParsedSource(repo_url=repo_url, subpath=subpath, handle=handle, name=name)
@@ -179,16 +179,16 @@ def _fetch_named_ralph(
179179
) -> FetchResult:
180180
"""Handle ``owner/repo/ralph-name`` — search or exact subpath."""
181181
assert parsed.subpath is not None
182+
ralph_name = parsed.name
182183

183184
# First try exact subpath.
184185
exact = clone_dir / parsed.subpath
185186
if exact.is_dir() and (exact / RALPH_MARKER).is_file():
186-
dest = ralphs_dir / parsed.name
187+
dest = ralphs_dir / ralph_name
187188
_copy_ralph(exact, dest)
188-
return FetchResult(installed=[(parsed.name, dest)])
189+
return FetchResult(installed=[(ralph_name, dest)])
189190

190191
# Search by name (leaf segment).
191-
ralph_name = parsed.name
192192
all_ralphs = _find_ralphs_in(clone_dir)
193193
matches = [rd for rd in all_ralphs if rd.name == ralph_name]
194194

0 commit comments

Comments
 (0)