SeaCogs/issuecards/api/wrapper.py
cswimr fdbc4c0810
Some checks failed
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 55s
Actions / Build Documentation (MkDocs) (pull_request) Failing after 1m1s
feat(issuecards): init
2025-03-28 09:56:44 -05:00

22 lines
1 KiB
Python

from ..models import Issue, Repository
from .forgejo import fetch_forgejo_issue
from .github import fetch_github_issue
from .gitlab import fetch_gitlab_issue, fetch_gitlab_merge_request
async def fetch_issue(repository: Repository, issue_number: int, gitlab_issue_type: str = "issue") -> Issue:
match repository.provider.service:
case "github":
if gitlab_issue_type == "merge_request":
raise ValueError("Wrong provider!")
return await fetch_github_issue(repository, issue_number)
case "forgejo":
if gitlab_issue_type == "merge_request":
raise ValueError("Wrong provider!")
return await fetch_forgejo_issue(repository, issue_number)
case "gitlab":
if gitlab_issue_type == "merge_request":
return await fetch_gitlab_merge_request(repository, issue_number)
return await fetch_gitlab_issue(repository, issue_number)
case _:
raise ValueError("Unsupported provider service: '%s'" % repository.provider.service)