Skip to content

Commit

Permalink
fix: solve linter issues & add venv to be gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
bra-i-am committed May 24, 2024
1 parent bf35153 commit b9df829
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__
/dist/
.idea/
.vscode/
venv
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=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}"')
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

0 comments on commit b9df829

Please sign in to comment.