From bc82baa9681e64c0aec853288dd05c1709509d08 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 13 Nov 2024 13:18:09 -0800 Subject: [PATCH] refactor: Reorder git ignored file check to handle non-git repos --- aider/commands.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 524cf7a28..5d938098d 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -737,16 +737,16 @@ class Commands: for matched_file in sorted(all_matched_files): abs_file_path = self.coder.abs_root_path(matched_file) - if self.coder.repo.git_ignored_file(matched_file): - self.io.tool_error(f"Can't add {matched_file} which is in gitignore") - continue - if not abs_file_path.startswith(self.coder.root) and not is_image_file(matched_file): self.io.tool_error( f"Can not add {abs_file_path}, which is not within {self.coder.root}" ) continue + if self.coder.repo and self.coder.repo.git_ignored_file(matched_file): + self.io.tool_error(f"Can't add {matched_file} which is in gitignore") + continue + if abs_file_path in self.coder.abs_fnames: self.io.tool_error(f"{matched_file} is already in the chat as an editable file") continue