From 817530ccb7767e5316cac0d038c3ef6ee20e03c2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 28 Sep 2024 14:42:07 -0700 Subject: [PATCH] fixed regression allowing non-repo files to move from /read to /add --- aider/commands.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index c3745a406..e177e77ca 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -711,11 +711,16 @@ class Commands: self.io.tool_error(f"{matched_file} is already in the chat as an editable file") continue elif abs_file_path in self.coder.abs_read_only_fnames: - self.coder.abs_read_only_fnames.remove(abs_file_path) - self.coder.abs_fnames.add(abs_file_path) - self.io.tool_output( - f"Moved {matched_file} from read-only to editable files in the chat" - ) + if self.coder.repo and self.coder.repo.path_in_repo(matched_file): + self.coder.abs_read_only_fnames.remove(abs_file_path) + self.coder.abs_fnames.add(abs_file_path) + self.io.tool_output( + f"Moved {matched_file} from read-only to editable files in the chat" + ) + else: + self.io.tool_error( + f"Cannot add {matched_file} as it's not part of the repository" + ) else: if is_image_file(matched_file) and not self.coder.main_model.accepts_images: self.io.tool_error(