|
7 | 7 | from pathlib import Path
|
8 | 8 | from subprocess import CalledProcessError
|
9 | 9 | from typing import TYPE_CHECKING
|
| 10 | +from urllib.parse import urljoin |
10 | 11 |
|
11 | 12 | from dulwich import porcelain
|
12 | 13 | from dulwich.client import HTTPUnauthorized
|
@@ -345,22 +346,13 @@ def _clone_submodules(cls, repo: Repo, main_url: str) -> None:
|
345 | 346 | path_relative = Path(path.decode("utf-8"))
|
346 | 347 | path_absolute = repo_root.joinpath(path_relative)
|
347 | 348 |
|
348 |
| - url_string = url.decode() |
| 349 | + url_string = url.decode("utf-8") |
349 | 350 | final_url = url_string
|
350 | 351 | submodule_is_relative = bool(
|
351 | 352 | relative_submodule_regex.search(url_string)
|
352 | 353 | )
|
353 | 354 | if submodule_is_relative:
|
354 |
| - # Find a root list of url sections to mutate according |
355 |
| - # to the relative url |
356 |
| - url_sections = [section + "/" for section in main_url.split("/")] |
357 |
| - directories_upward = url_string.count("../") |
358 |
| - # Walk up the main URL until we know where to insert |
359 |
| - # the submodule URL |
360 |
| - url_portion_remaining = "".join(url_sections[:-directories_upward]) |
361 |
| - # Insert the submodule URL - the last segment of url_string.split() |
362 |
| - # is the path relative to the main URL |
363 |
| - final_url = url_portion_remaining + url_string.split("../")[-1] |
| 355 | + final_url = urljoin(f"{Git.get_remote_url(repo)}/", url_string) |
364 | 356 |
|
365 | 357 | source_root = path_absolute.parent
|
366 | 358 | source_root.mkdir(parents=True, exist_ok=True)
|
|
0 commit comments