Skip to content

Commit

Permalink
fix: solve linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bra-i-am committed May 27, 2024
1 parent bf35153 commit e85ae9f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=False
)
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=False
)

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=False
)

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}"')
5 changes: 2 additions & 3 deletions tutordistro/distro/share/domain/cloud_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']}/"
Expand Down

0 comments on commit e85ae9f

Please sign in to comment.