Skip to content

Commit 7afaa26

Browse files
Merge pull request #4674 from chr15m/add-readonly-no-git
2 parents cf72acf + f730853 commit 7afaa26

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
@@ -868,7 +868,13 @@ def cmd_add(self, args):
868868
self.io.tool_error(f"{matched_file} is already in the chat as an editable file")
869869
continue
870870
elif abs_file_path in self.coder.abs_read_only_fnames:
871-
if self.coder.repo and self.coder.repo.path_in_repo(matched_file):
871+
# Determine if file can be promoted to editable
872+
if self.coder.repo:
873+
can_edit = self.coder.repo.path_in_repo(matched_file)
874+
else:
875+
can_edit = abs_file_path.startswith(self.coder.root)
876+
877+
if can_edit:
872878
self.coder.abs_read_only_fnames.remove(abs_file_path)
873879
self.coder.abs_fnames.add(abs_file_path)
874880
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)