First MVP
This commit is contained in:
35
src/gitea_codex_bot/services/repo_config.py
Normal file
35
src/gitea_codex_bot/services/repo_config.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class RepoReviewConfig:
|
||||
enabled: bool = True
|
||||
default_mode: str = "summary"
|
||||
max_diff_bytes: int = 200000
|
||||
include_tests: bool = True
|
||||
focus: list[str] = field(default_factory=lambda: ["correctness", "security", "maintainability"])
|
||||
ignore: list[str] = field(default_factory=list)
|
||||
allow_fix: bool = False
|
||||
|
||||
|
||||
def load_repo_review_config(repo_root: Path) -> RepoReviewConfig:
|
||||
path = repo_root / ".codex-review.yml"
|
||||
if not path.exists():
|
||||
return RepoReviewConfig()
|
||||
raw = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
||||
review = raw.get("review", {}) or {}
|
||||
commands = raw.get("commands", {}) or {}
|
||||
return RepoReviewConfig(
|
||||
enabled=bool(raw.get("enabled", True)),
|
||||
default_mode=str(review.get("default_mode", "summary")),
|
||||
max_diff_bytes=int(review.get("max_diff_bytes", 200000)),
|
||||
include_tests=bool(review.get("include_tests", True)),
|
||||
focus=list(review.get("focus", ["correctness", "security", "maintainability"])),
|
||||
ignore=list(raw.get("ignore", [])),
|
||||
allow_fix=bool(commands.get("allow_fix", False)),
|
||||
)
|
||||
Reference in New Issue
Block a user