From 3af97ab8f6076a5770c12db50163cf8e174370be Mon Sep 17 00:00:00 2001 From: "Jon Michael Aanes (aider)" Date: Sun, 13 Apr 2025 18:20:00 +0200 Subject: [PATCH 1/2] refactor: Update run_cmd to return subprocess result and handle Aider invocation errors --- aider_gitea/__main__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/aider_gitea/__main__.py b/aider_gitea/__main__.py index ddf8197..a022824 100644 --- a/aider_gitea/__main__.py +++ b/aider_gitea/__main__.py @@ -211,9 +211,9 @@ def has_commits_on_branch(cwd: Path, base_branch: str, current_branch: str) -> b return False -def run_cmd(cmd: list[str], cwd: Path | None = None, check=True) -> None: +def run_cmd(cmd: list[str], cwd: Path | None = None, check=True) -> subprocess.CompletedProcess: print(cmd) - subprocess.run(cmd, check=check, cwd=cwd) + return subprocess.run(cmd, check=check, cwd=cwd) def solve_issue_in_repository( @@ -236,7 +236,14 @@ def solve_issue_in_repository( run_cmd(['git', 'checkout', '-b', branch_name], tmpdirname) # Run aider - run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname) + try: + aider_result = run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname) + if aider_result.returncode != 0: + logger.error(f"Aider invocation failed for issue #{issue_number}") + return False + except subprocess.CalledProcessError: + logger.exception(f"Aider invocation failed with an exception for issue #{issue_number}") + return False # Auto-fix standard code quality stuff run_cmd(['bash', '-c', RUFF_FORMAT_AND_AUTO_FIX], tmpdirname, check=False) -- 2.45.1 From 78c995c1a7a44b86235155e6b21cfb61900bffbf Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 13 Apr 2025 18:20:04 +0200 Subject: [PATCH 2/2] Ruff --- aider_gitea/__main__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/aider_gitea/__main__.py b/aider_gitea/__main__.py index a022824..50fed56 100644 --- a/aider_gitea/__main__.py +++ b/aider_gitea/__main__.py @@ -211,7 +211,9 @@ def has_commits_on_branch(cwd: Path, base_branch: str, current_branch: str) -> b return False -def run_cmd(cmd: list[str], cwd: Path | None = None, check=True) -> subprocess.CompletedProcess: +def run_cmd( + cmd: list[str], cwd: Path | None = None, check=True, +) -> subprocess.CompletedProcess: print(cmd) return subprocess.run(cmd, check=check, cwd=cwd) @@ -237,12 +239,16 @@ def solve_issue_in_repository( # Run aider try: - aider_result = run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname) + aider_result = run_cmd( + create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname, + ) if aider_result.returncode != 0: - logger.error(f"Aider invocation failed for issue #{issue_number}") + logger.error(f'Aider invocation failed for issue #{issue_number}') return False except subprocess.CalledProcessError: - logger.exception(f"Aider invocation failed with an exception for issue #{issue_number}") + logger.exception( + f'Aider invocation failed with an exception for issue #{issue_number}', + ) return False # Auto-fix standard code quality stuff -- 2.45.1