Feat/tool based coordinator routing (#5)
Co-authored-by: Michael <michael@example.com> Reviewed-on: #5
This commit is contained in:
+7
-4
@@ -1,9 +1,12 @@
|
||||
import os
|
||||
import logging
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
from .config import GITEA_REPOS_ROOT, GITEA_URL, GITEA_TOKEN
|
||||
|
||||
logger: logging.Logger = logging.getLogger("gitea-workspace")
|
||||
|
||||
|
||||
class WorkspaceManager:
|
||||
"""Manages local workspace for Gitea repositories."""
|
||||
@@ -29,7 +32,7 @@ class WorkspaceManager:
|
||||
capture_output=True
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Error unsetting global configs: {e}")
|
||||
logger.error(f"Error unsetting global configs: {e}")
|
||||
|
||||
def _configure_repo_user(self, repo_path: Path) -> None:
|
||||
try:
|
||||
@@ -64,7 +67,7 @@ class WorkspaceManager:
|
||||
check=True, capture_output=True
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Error configuring local git user: {e}")
|
||||
logger.error(f"Error configuring local git user: {e}")
|
||||
|
||||
def get_repo_path(self, repo_full_name: str) -> Path:
|
||||
parts: list[str] = repo_full_name.split("/")
|
||||
@@ -112,7 +115,7 @@ class WorkspaceManager:
|
||||
check=True, capture_output=True,
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Error during sanitization: {e}")
|
||||
logger.error(f"Error during sanitization: {e}")
|
||||
|
||||
def clone_repo(self, repo_full_name: str, clone_url: str | None = None) -> Path:
|
||||
repo_path: Path = self.get_repo_path(repo_full_name)
|
||||
@@ -125,7 +128,7 @@ class WorkspaceManager:
|
||||
repo_path.rename(new_path)
|
||||
return repo_path
|
||||
|
||||
print(f"Cloning repository {repo_full_name} to {repo_path}...")
|
||||
logger.info(f"Cloning repository {repo_full_name} to {repo_path}...")
|
||||
auth_url = self._get_authenticated_url(repo_full_name)
|
||||
subprocess.run(["git", "clone", auth_url, str(repo_path)], check=True, capture_output=True)
|
||||
self._configure_repo_user(repo_path)
|
||||
|
||||
Reference in New Issue
Block a user