From ba7e13585ff15389a8e885514b743dc78c2e2904 Mon Sep 17 00:00:00 2001 From: Brayan Ceron Date: Fri, 24 May 2024 11:39:54 -0500 Subject: [PATCH] fix: solve linter issues & add venv to be gitignore --- .gitignore | 1 + .../infrastructure/package_git_repository.py | 1 + .../infrastructure/git_package_repository.py | 17 +++++++++++++---- .../distro/share/domain/cloud_package.py | 5 ++--- .../infraestructure/theme_git_repository.py | 1 + 5 files changed, 18 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/packages/infrastructure/package_git_repository.py b/tutordistro/distro/packages/infrastructure/package_git_repository.py index e7e6442..d779cd6 100644 --- a/tutordistro/distro/packages/infrastructure/package_git_repository.py +++ b/tutordistro/distro/packages/infrastructure/package_git_repository.py @@ -52,6 +52,7 @@ def clone(self, package: Package, path: str) -> None: package (Package): The package to be cloned. path (str): The destination path for cloning the package. """ + repo = None if "https" == package.extra["protocol"]: repo = ( f"https://{package.domain}/" 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 diff --git a/tutordistro/distro/themes/infraestructure/theme_git_repository.py b/tutordistro/distro/themes/infraestructure/theme_git_repository.py index 24678b4..a06c9d2 100644 --- a/tutordistro/distro/themes/infraestructure/theme_git_repository.py +++ b/tutordistro/distro/themes/infraestructure/theme_git_repository.py @@ -32,6 +32,7 @@ def clone(self, theme_settings: type(ThemeSettings)): Args: theme_settings (ThemeSettings): Theme settings. """ + repo = None if "https" == theme_settings.settings["protocol"]: repo = ( f"https://{theme_settings.settings['domain']}/"