Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_git_root():
try:
repo = git.Repo(search_parent_directories=True)
return repo.working_tree_dir
except (git.InvalidGitRepositoryError, FileNotFoundError):
except (git.InvalidGitRepositoryError, git.NoSuchPathError, FileNotFoundError):
return None


Expand Down
16 changes: 15 additions & 1 deletion tests/basic/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from aider.coders import Coder
from aider.dump import dump # noqa: F401
from aider.io import InputOutput
from aider.main import check_gitignore, load_dotenv_files, main, setup_git
from aider.main import check_gitignore, get_git_root, load_dotenv_files, main, setup_git
from aider.utils import GitTemporaryDirectory, IgnorantTemporaryDirectory, make_repo


Expand Down Expand Up @@ -1164,6 +1164,20 @@ def test_main_exit_with_git_command_not_found(self, mock_git_init):

self.assertIsNone(result, "main() should return None when called with --exit")

@patch("aider.main.git.Repo")
def test_get_git_root_no_such_path_error(self, mock_repo):
"""get_git_root should return None when NoSuchPathError is raised (issue #2957)."""
mock_repo.side_effect = git.exc.NoSuchPathError("/nonexistent/path")
result = get_git_root()
self.assertIsNone(result)

@patch("aider.main.git.Repo")
def test_get_git_root_invalid_repo(self, mock_repo):
"""get_git_root should return None when InvalidGitRepositoryError is raised."""
mock_repo.side_effect = git.InvalidGitRepositoryError("/some/path")
result = get_git_root()
self.assertIsNone(result)

def test_reasoning_effort_option(self):
coder = main(
["--reasoning-effort", "3", "--no-check-model-accepts-settings", "--yes", "--exit"],
Expand Down
Loading