File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2216,7 +2216,7 @@ def allowed_to_edit(self, path):
22162216 # Seems unlikely that we needed to create the file, but it was
22172217 # actually already part of the repo.
22182218 # But let's only add if we need to, just to be safe.
2219- if need_to_add :
2219+ if need_to_add and self . auto_commits :
22202220 self .repo .repo .git .add (full_path )
22212221
22222222 self .abs_fnames .add (full_path )
@@ -2230,7 +2230,7 @@ def allowed_to_edit(self, path):
22302230 self .io .tool_output (f"Skipping edits to { path } " )
22312231 return
22322232
2233- if need_to_add :
2233+ if need_to_add and self . auto_commits :
22342234 self .repo .repo .git .add (full_path )
22352235
22362236 self .abs_fnames .add (full_path )
Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -95,7 +95,10 @@ def is_image_file(file_name):
9595
9696def safe_abs_path (res ):
9797 "Gives an abs path, which safely returns a full (not 8.3) windows path"
98- res = Path (res ).resolve ()
98+ try :
99+ res = Path (res ).resolve ()
100+ except (RuntimeError , OSError ):
101+ res = Path (res ).absolute ()
99102 return str (res )
100103
101104
Original file line number Diff line number Diff line change 1+ import os
2+
3+ from aider .utils import safe_abs_path
4+
5+
6+ def test_safe_abs_path_symlink_loop (tmp_path ):
7+ # Create circular symlink: a -> b -> a
8+ link_a = tmp_path / "link_a"
9+ link_b = tmp_path / "link_b"
10+ link_a .symlink_to (link_b )
11+ link_b .symlink_to (link_a )
12+
13+ # safe_abs_path must not raise, and must return an absolute path
14+ result = safe_abs_path (str (link_a ))
15+ assert os .path .isabs (result )
You can’t perform that action at this time.
0 commit comments