feat. Enforce repo review config
This commit is contained in:
@@ -13,6 +13,7 @@ from typing import Any
|
||||
|
||||
from gitea_codex_bot.config import Settings
|
||||
from gitea_codex_bot.services.gitea import GiteaClient
|
||||
from gitea_codex_bot.services.repo_config import RepoReviewConfig
|
||||
from gitea_codex_bot.services.reviewer import normalize_review_result, prepare_review_prompt, run_review_for_pr
|
||||
from gitea_codex_bot.types import ParsedCommand
|
||||
|
||||
@@ -26,9 +27,9 @@ def run_review_ephemeral(
|
||||
repo: str,
|
||||
pr_number: int,
|
||||
command: ParsedCommand,
|
||||
) -> dict[str, Any]:
|
||||
) -> tuple[dict[str, Any], RepoReviewConfig]:
|
||||
gitea = GiteaClient(settings)
|
||||
prompt, _diff_context, _repo_cfg = prepare_review_prompt(settings, gitea, repo, pr_number, command)
|
||||
prompt, _diff_context, repo_cfg = prepare_review_prompt(settings, gitea, repo, pr_number, command)
|
||||
container_name = f"codex-review-{uuid.uuid4().hex[:12]}"
|
||||
install_and_run = _build_install_and_run_command(settings)
|
||||
extra_env: dict[str, str] = {}
|
||||
@@ -49,13 +50,13 @@ def run_review_ephemeral(
|
||||
raise RuntimeError(_format_runner_failure(completed))
|
||||
parsed = _parse_codex_exec_stdout(completed.stdout)
|
||||
parsed["_meta"] = _extract_result_meta_from_codex_stdout(completed.stdout, settings)
|
||||
return normalize_review_result(parsed)
|
||||
return normalize_review_result(parsed), repo_cfg
|
||||
except Exception as exc:
|
||||
if settings.codex_auth_mode == "chatgpt":
|
||||
logger.warning("Ephemeral chatgpt runner failed, skipping API-key fallback: %s", exc)
|
||||
return _chatgpt_runner_failure_result(exc)
|
||||
return _chatgpt_runner_failure_result(exc), repo_cfg
|
||||
result, _repo_cfg = run_review_for_pr(settings, gitea, repo, pr_number, command)
|
||||
return result
|
||||
return result, _repo_cfg
|
||||
|
||||
|
||||
def _build_install_and_run_command(settings: Settings) -> str:
|
||||
|
||||
Reference in New Issue
Block a user