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
6 changes: 6 additions & 0 deletions aider/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ def __init__(

# https://github.com/gitpython-developers/GitPython/issues/427
self.repo = git.Repo(repo_paths.pop(), odbt=git.GitDB)

if not self.repo.working_tree_dir:
raise FileNotFoundError(
"The git repo does not seem to have a working tree?"
)

self.root = utils.safe_abs_path(self.repo.working_tree_dir)

if aider_ignore_file:
Expand Down
7 changes: 7 additions & 0 deletions tests/basic/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,10 @@ def test_get_commit_message_uses_system_prompt_prefix(self, mock_send):
system_msg_content.startswith(prefix),
"system_prompt_prefix should be prepended to the system prompt",
)

def test_bare_repo_raises_file_not_found(self):
with tempfile.TemporaryDirectory() as tmpdir:
bare_path = Path(tmpdir) / "bare.git"
git.Repo.init(str(bare_path), bare=True)
with self.assertRaises(FileNotFoundError):
GitRepo(InputOutput(), None, str(bare_path))