fix chdir

This commit is contained in:
Michael Ingvarsson
2026-07-16 12:27:04 +02:00
parent e54b5f1848
commit b47a3b3146
2 changed files with 35 additions and 49 deletions
-12
View File
@@ -2,7 +2,6 @@
import logging import logging
import re import re
import os
import subprocess import subprocess
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Any, Callable from typing import Any, Callable
@@ -677,14 +676,7 @@ class AgentDispatcher:
workspace = WorkspaceManager() workspace = WorkspaceManager()
repo_path = workspace.get_repo_path(repo) repo_path = workspace.get_repo_path(repo)
original_cwd = os.getcwd()
changed_dir = False
if os.path.isdir(str(repo_path)):
os.chdir(str(repo_path))
changed_dir = True
results: list[str] = [] results: list[str] = []
try:
# Get authenticated username for reviewer filter # Get authenticated username for reviewer filter
ai_username = "meeks-ai" ai_username = "meeks-ai"
try: try:
@@ -723,10 +715,6 @@ class AgentDispatcher:
result = await processor.process(attempt_limit=self._max_retries) result = await processor.process(attempt_limit=self._max_retries)
results.append(result) results.append(result)
finally:
if changed_dir:
os.chdir(original_cwd)
return results return results
# Backward compatibility helper methods for unit tests # Backward compatibility helper methods for unit tests
-2
View File
@@ -137,8 +137,6 @@ async def test_dispatch_planning_and_coding_phases(mock_planning_class: MagicMoc
priority=0 priority=0
) )
# We mock os.path.isdir to return True so os.chdir won't fail or crash in test
with patch("os.path.isdir", return_value=True), patch("os.chdir"):
results = await dispatcher.dispatch("meeks/repo1", [work_item]) results = await dispatcher.dispatch("meeks/repo1", [work_item])
assert len(results) == 1 assert len(results) == 1