diff --git a/spacy/cli/_util.py b/spacy/cli/_util.py index b03f3eb69..0755ccb46 100644 --- a/spacy/cli/_util.py +++ b/spacy/cli/_util.py @@ -360,5 +360,7 @@ def _from_http_to_git(repo): repo = repo.replace(r"http://", r"https://") if repo.startswith(r"https://"): repo = repo.replace("https://", "git@").replace("/", ":", 1) + if repo.endswith("/"): + repo = repo[:-1] repo = f"{repo}.git" return repo diff --git a/spacy/cli/project/assets.py b/spacy/cli/project/assets.py index 2b623675d..cb3a2fb99 100644 --- a/spacy/cli/project/assets.py +++ b/spacy/cli/project/assets.py @@ -38,16 +38,21 @@ def project_assets(project_dir: Path) -> None: msg.warn(f"No assets specified in {PROJECT_FILE}", exits=0) msg.info(f"Fetching {len(assets)} asset(s)") for asset in assets: - dest = Path(asset["dest"]) + dest = (project_dir / asset["dest"]).resolve() checksum = asset.get("checksum") if "git" in asset: if dest.exists(): # If there's already a file, check for checksum if checksum and checksum == get_checksum(dest): - msg.good(f"Skipping download with matching checksum: {dest}") + msg.good( + f"Skipping download with matching checksum: {asset['dest']}" + ) continue else: - shutil.rmtree(dest) + if dest.is_dir(): + shutil.rmtree(dest) + else: + dest.unlink() git_sparse_checkout( asset["git"]["repo"], asset["git"]["path"], @@ -67,7 +72,7 @@ def check_private_asset(dest: Path, checksum: Optional[str] = None) -> None: """Check and validate assets without a URL (private assets that the user has to provide themselves) and give feedback about the checksum. - dest (Path): Desintation path of the asset. + dest (Path): Destination path of the asset. checksum (Optional[str]): Optional checksum of the expected file. """ if not Path(dest).exists():