From b9df829a941b8edd8a18b420c3c6fdadde68e663 Mon Sep 17 00:00:00 2001 From: Brayan Ceron Date: Fri, 24 May 2024 11:35:29 -0500 Subject: [PATCH] fix: solve linter issues & add venv to be gitignore --- .gitignore | 1 + .../infrastructure/git_package_repository.py | 17 +++++++++++++---- .../distro/share/domain/cloud_package.py | 5 ++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d3b24c9..3da454a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ __pycache__ /dist/ .idea/ .vscode/ +venv \ No newline at end of file diff --git a/tutordistro/distro/repository_validator/infrastructure/git_package_repository.py b/tutordistro/distro/repository_validator/infrastructure/git_package_repository.py index c6233a6..9c1f861 100644 --- a/tutordistro/distro/repository_validator/infrastructure/git_package_repository.py +++ b/tutordistro/distro/repository_validator/infrastructure/git_package_repository.py @@ -25,14 +25,23 @@ def validate(self, package: CloudPackage) -> None: version_name = package_url.split('/tree/')[1] # Verify that exist the repository - repo_verification_output = subprocess.run(f'git ls-remote {repo_url}', shell=True, capture_output=True) + repo_verification_output = subprocess.run( + f'git ls-remote {repo_url}', + shell=True, capture_output=True, check=True + ) if repo_verification_output.returncode != 0: raise PackageDoesNotExist(f'The package "{repo_url}" does not exist or is private') # Verify that the branch/tag is valid - branch_verification_output = subprocess.run(f'git ls-remote --heads "{repo_url}" "{version_name}" | grep "refs/heads/{version_name}"', shell=True, capture_output=True) + branch_verification_output = subprocess.run( + f'git ls-remote --heads "{repo_url}" "{version_name}" | grep "refs/heads/{version_name}"', + shell=True, capture_output=True, check=True + ) - tag_verification_output = subprocess.run(f'git ls-remote --tags {repo_url} | grep "refs/tags/{version_name}"', shell=True, capture_output=True) + tag_verification_output = subprocess.run( + f'git ls-remote --tags {repo_url} | grep "refs/tags/{version_name}"', + shell=True, capture_output=True, check=True + ) if branch_verification_output.returncode != 0 and tag_verification_output.returncode != 0: - raise PackageDoesNotExist(f'Neither branch nor tag "{version_name}" exists on "{repo_url}"') + raise PackageDoesNotExist(f'Neither branch nor tag "{version_name}" exists on "{repo_url}"') diff --git a/tutordistro/distro/share/domain/cloud_package.py b/tutordistro/distro/share/domain/cloud_package.py index eec0993..705bfab 100644 --- a/tutordistro/distro/share/domain/cloud_package.py +++ b/tutordistro/distro/share/domain/cloud_package.py @@ -11,7 +11,6 @@ from urllib.parse import urlparse from tutordistro.distro.share.domain.package import Package -from tutordistro.distro.share.domain.package_does_not_exist import PackageDoesNotExist class CloudPackage: @@ -64,8 +63,8 @@ def __parse_url(url) -> CloudPackage: split_path = full_path.split('/') package_name = split_path[2] - version_name = found_package_url.split("@")[-1] # This is the branch name or tag - + version_name = found_package_url.split("@")[-1] # This is the branch name or tag + if '/tree/' in github_url: version = version_name