feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
"""Forgejo repository model storing organization-level tracked repository metadata."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from uuid import UUID, uuid4
|
|
|
|
|
|
2026-05-19 21:34:11 -05:00
|
|
|
from sqlalchemy import Column
|
|
|
|
|
from sqlalchemy import JSON
|
feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
from sqlmodel import Field
|
|
|
|
|
|
|
|
|
|
from app.core.time import utcnow
|
|
|
|
|
from app.models.base import QueryModel
|
|
|
|
|
|
|
|
|
|
RUNTIME_ANNOTATION_TYPES = (datetime,)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoRepository(QueryModel, table=True):
|
|
|
|
|
"""Tracked Forgejo repository for organization."""
|
|
|
|
|
|
|
|
|
|
__tablename__ = "forgejo_repositories" # pyright: ignore[reportAssignmentType]
|
|
|
|
|
|
|
|
|
|
id: UUID = Field(default_factory=uuid4, primary_key=True)
|
|
|
|
|
organization_id: UUID = Field(foreign_key="organizations.id", index=True)
|
|
|
|
|
connection_id: UUID = Field(foreign_key="forgejo_connections.id", index=True)
|
|
|
|
|
owner: str
|
|
|
|
|
repo: str
|
|
|
|
|
display_name: str = Field(default="")
|
|
|
|
|
default_branch: str = Field(default="main")
|
|
|
|
|
active: bool = Field(default=True)
|
2026-05-19 04:16:32 -05:00
|
|
|
webhook_secret: str | None = Field(default=None)
|
2026-05-19 21:49:45 -05:00
|
|
|
description: str | None = Field(default=None)
|
|
|
|
|
open_issues_count: int = Field(default=0)
|
|
|
|
|
is_archived: bool = Field(default=False)
|
|
|
|
|
topics: list[str] = Field(
|
|
|
|
|
default_factory=list,
|
|
|
|
|
sa_column=Column(JSON, nullable=False, server_default="[]"),
|
|
|
|
|
)
|
2026-05-19 21:34:11 -05:00
|
|
|
labels: list[dict[str, object]] = Field(
|
|
|
|
|
default_factory=list,
|
|
|
|
|
sa_column=Column(JSON, nullable=False, server_default="[]"),
|
|
|
|
|
)
|
feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
last_sync_at: datetime | None = Field(default=None)
|
|
|
|
|
last_sync_error: str | None = Field(default=None)
|
|
|
|
|
created_at: datetime = Field(default_factory=utcnow)
|
|
|
|
|
updated_at: datetime = Field(default_factory=utcnow)
|