fix: parts of the code

This commit is contained in:
Eduardo Chiarotti
2024-08-21 17:33:59 -03:00
parent 414a9ba07e
commit d4d7712164
2 changed files with 11 additions and 9 deletions

View File

@@ -104,7 +104,7 @@ class DeployCommand:
remote_repo_url = get_git_remote_url() remote_repo_url = get_git_remote_url()
self._confirm_input(env_vars, remote_repo_url) self._confirm_input(env_vars, remote_repo_url)
payload = self._create_payload(remote_repo_url, env_vars) payload = self._create_payload(env_vars, remote_repo_url)
response = self.client.create_crew(payload) response = self.client.create_crew(payload)
if response.status_code == 201: if response.status_code == 201:
@@ -126,7 +126,9 @@ class DeployCommand:
) )
def _create_payload( def _create_payload(
self, remote_repo_url: str, env_vars: Dict[str, str] self,
env_vars: Dict[str, str],
remote_repo_url: str,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
""" """
Create the payload for crew creation. Create the payload for crew creation.

View File

@@ -4,7 +4,8 @@ import subprocess
import tomllib import tomllib
def get_git_remote_url(): def get_git_remote_url() -> str:
"""Get the Git repository's remote URL."""
try: try:
# Run the git remote -v command # Run the git remote -v command
result = subprocess.run( result = subprocess.run(
@@ -21,18 +22,16 @@ def get_git_remote_url():
return matches[0] # Return the first match (origin URL) return matches[0] # Return the first match (origin URL)
else: else:
print("No origin remote found.") print("No origin remote found.")
return None return "No remote URL found"
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print(f"Error running trying to fetch the Git Repository: {e}") return f"Error running trying to fetch the Git Repository: {e}"
return None
except FileNotFoundError: except FileNotFoundError:
print("Git command not found. Make sure Git is installed and in your PATH.") return "Git command not found. Make sure Git is installed and in your PATH."
return None
def get_project_name(pyproject_path: str = "pyproject.toml"): def get_project_name(pyproject_path: str = "pyproject.toml"):
"""Get the project name from the pyproject.toml file."""
try: try:
# Read the pyproject.toml file # Read the pyproject.toml file
with open(pyproject_path, "rb") as f: with open(pyproject_path, "rb") as f:
@@ -59,6 +58,7 @@ def get_project_name(pyproject_path: str = "pyproject.toml"):
def fetch_and_json_env_file(env_file_path: str = ".env") -> dict: def fetch_and_json_env_file(env_file_path: str = ".env") -> dict:
"""Fetch the environment variables from a .env file and return them as a dictionary."""
try: try:
# Read the .env file # Read the .env file
with open(env_file_path, "r") as f: with open(env_file_path, "r") as f: