[refactor]. Remove legacy review prompt path
This commit is contained in:
@@ -4,6 +4,7 @@ import base64
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import uuid
|
||||
@@ -63,6 +64,7 @@ def run_review_ephemeral(
|
||||
gitea = GiteaClient(settings)
|
||||
pr = gitea.get_pull_request(repo, pr_number)
|
||||
repo_cfg = _load_repo_review_config_from_gitea(gitea, repo, pr.head_sha)
|
||||
review_prompt = _build_exec_review_prompt(command)
|
||||
container_name = f"codex-review-{uuid.uuid4().hex[:12]}"
|
||||
extra_env: dict[str, str] = {
|
||||
"GITEA_TOKEN": settings.gitea_token.get_secret_value(),
|
||||
@@ -81,6 +83,7 @@ def run_review_ephemeral(
|
||||
settings,
|
||||
pr=pr,
|
||||
container_name=container_name,
|
||||
review_prompt=review_prompt,
|
||||
extra_env=extra_env,
|
||||
)
|
||||
if completed.returncode != 0:
|
||||
@@ -98,9 +101,10 @@ def _run_ephemeral_container(
|
||||
*,
|
||||
pr: PullRequestContext,
|
||||
container_name: str,
|
||||
review_prompt: str,
|
||||
extra_env: dict[str, str],
|
||||
) -> subprocess.CompletedProcess[str]:
|
||||
install_and_run = _build_install_and_run_command(settings, pr=pr)
|
||||
install_and_run = _build_install_and_run_command(settings, pr=pr, review_prompt=review_prompt)
|
||||
cmd = _build_docker_command(settings, container_name=container_name, install_and_run=install_and_run)
|
||||
return subprocess.run(
|
||||
cmd,
|
||||
@@ -116,6 +120,7 @@ def _build_install_and_run_command(
|
||||
settings: Settings,
|
||||
*,
|
||||
pr: PullRequestContext,
|
||||
review_prompt: str,
|
||||
) -> str:
|
||||
steps = ["set -euo pipefail"]
|
||||
if settings.codex_auth_mode != "chatgpt":
|
||||
@@ -172,8 +177,7 @@ def _build_install_and_run_command(
|
||||
)
|
||||
model = settings.openai_review_model.strip()
|
||||
codex_exec_parts = [
|
||||
"codex exec review",
|
||||
f"--base {shlex.quote(pr.base_sha)}",
|
||||
"codex exec",
|
||||
"--json",
|
||||
"--output-schema",
|
||||
shlex.quote(REVIEW_SCHEMA_FILE),
|
||||
@@ -182,6 +186,7 @@ def _build_install_and_run_command(
|
||||
]
|
||||
if model:
|
||||
codex_exec_parts.append(f"-m {shlex.quote(model)}")
|
||||
codex_exec_parts.append(shlex.quote(review_prompt))
|
||||
steps.extend(
|
||||
[
|
||||
" ".join(codex_exec_parts),
|
||||
@@ -193,6 +198,17 @@ def _build_install_and_run_command(
|
||||
return "\n".join(steps)
|
||||
|
||||
|
||||
def _build_exec_review_prompt(command: ParsedCommand) -> str:
|
||||
raw = (command.raw or "").strip()
|
||||
remainder = raw
|
||||
match = re.match(r"^@[^\s]+\s+\S+\s*(.*)$", raw, flags=re.IGNORECASE | re.DOTALL)
|
||||
if match:
|
||||
remainder = match.group(1).strip()
|
||||
if not remainder:
|
||||
return "review: review this pull request and report introduced issues."
|
||||
return f"review: {remainder}"
|
||||
|
||||
|
||||
def _build_docker_command(settings: Settings, *, container_name: str, install_and_run: str) -> list[str]:
|
||||
cmd = [
|
||||
"docker",
|
||||
|
||||
Reference in New Issue
Block a user