Skip to content

Commit f730853

Browse files
committed
Allow adding read-only files to editable with git: false.
1 parent f626e44 commit f730853

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

aider/commands.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,13 @@ def cmd_add(self, args):
864864
self.io.tool_error(f"{matched_file} is already in the chat as an editable file")
865865
continue
866866
elif abs_file_path in self.coder.abs_read_only_fnames:
867-
if self.coder.repo and self.coder.repo.path_in_repo(matched_file):
867+
# Determine if file can be promoted to editable
868+
if self.coder.repo:
869+
can_edit = self.coder.repo.path_in_repo(matched_file)
870+
else:
871+
can_edit = abs_file_path.startswith(self.coder.root)
872+
873+
if can_edit:
868874
self.coder.abs_read_only_fnames.remove(abs_file_path)
869875
self.coder.abs_fnames.add(abs_file_path)
870876
self.io.tool_output(

aider/repo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@ def path_in_repo(self, path):
571571
return
572572

573573
tracked_files = set(self.get_tracked_files())
574-
return self.normalize_path(path) in tracked_files
574+
normalized = self.normalize_path(path)
575+
return normalized in tracked_files
575576

576577
def abs_root_path(self, path):
577578
res = Path(self.root) / path

0 commit comments

Comments
 (0)