refactor: Reorder git ignored file check to handle non-git repos

This commit is contained in:
Paul Gauthier 2024-11-13 13:18:09 -08:00 committed by Paul Gauthier (aider)
parent 218623be28
commit bc82baa968

View file

@ -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