Merge pull request #6049 from svlandeg/feature/project-fixes

This commit is contained in:
Ines Montani 2020-09-11 09:57:40 +02:00 committed by GitHub
commit 2247d62655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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():