fix: Use os.path.commonpath() to check if fname_path is below cwd_path

This commit is contained in:
Paul Gauthier (aider) 2024-08-01 16:28:10 -03:00
parent f26862d92c
commit 24aa48198b

View file

@ -269,14 +269,11 @@ class GitRepo:
def ignored_file_raw(self, fname): def ignored_file_raw(self, fname):
if self.subtree_only: if self.subtree_only:
try:
fname_path = Path(self.normalize_path(fname)).resolve() fname_path = Path(self.normalize_path(fname)).resolve()
cwd_path = Path.cwd().resolve() cwd_path = Path.cwd().resolve()
dump(fname_path) dump(fname_path)
dump(cwd_path) dump(cwd_path)
if not fname_path.is_relative_to(cwd_path): if os.path.commonpath([str(fname_path), str(cwd_path)]) != str(cwd_path):
return True
except ValueError:
return True return True
if not self.aider_ignore_file or not self.aider_ignore_file.is_file(): if not self.aider_ignore_file or not self.aider_ignore_file.is_file():