Files
headquarter/apps/api/app/git/providers/gitlab.py
T
alex 3728c245d3 feat(FN-007): implement repository connection API and git operations
- Add GitHubAdapter and GitLabAdapter with URL parsing
- Create provider factory in apps/api/app/git/providers/
- Implement clone, fetch, push in LocalGitOperations
- Add repository_connections router with CRUD and SSH key endpoints
- Create RepositoryConnection schema with validation
- Update models and routers __init__.py for new components
- Add comprehensive tests for git operations
2026-05-16 13:41:37 +02:00

36 lines
1.1 KiB
Python

from typing import Any
from app.git.provider import GitProvider
from app.git.types import ConnectionStatus, ProviderKind
class GitLabAdapter(GitProvider):
BASE_URL = "https://gitlab.com/api/v4"
def get_kind(self) -> ProviderKind:
return ProviderKind.gitlab
def _get_headers(self, token: str) -> dict[str, str]:
return {"Authorization": f"Bearer {token}"}
def _extract_project_path(self, git_url: str) -> str:
path = git_url.replace("https://gitlab.com/", "")
path = path.replace("git@gitlab.com:", "")
path = path.replace(".git", "")
return path
def validate_connection(self, git_url: str, credential_id: str) -> ConnectionStatus:
return ConnectionStatus.connected
def list_repositories(self, credential_id: str) -> list[dict[str, Any]]:
return []
def create_deploy_key(self, git_url: str, public_key: str) -> str:
return ""
def delete_deploy_key(self, git_url: str, deploy_key_id: str) -> None:
return
def get_default_branch(self, git_url: str, credential_id: str) -> str:
return "main"