fix: Improve handling of ignored files in GitRepo class

This commit is contained in:
Paul Gauthier 2024-08-01 16:25:40 -03:00 committed by Paul Gauthier (aider)
parent f458fa86ac
commit 17e2c02a47

View file

@ -259,6 +259,7 @@ class GitRepo:
return str(Path(PurePosixPath((Path(self.root) / path).relative_to(self.root)))) return str(Path(PurePosixPath((Path(self.root) / path).relative_to(self.root))))
def ignored_file(self, fname): def ignored_file(self, fname):
orig_fname = fname
if fname in self.ignore_file_cache: if fname in self.ignore_file_cache:
return self.ignore_file_cache[fname] return self.ignore_file_cache[fname]
@ -266,6 +267,7 @@ class GitRepo:
try: 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()
if not fname_path.is_relative_to(cwd_path): if not fname_path.is_relative_to(cwd_path):
return True return True
except ValueError: except ValueError:
@ -290,7 +292,7 @@ class GitRepo:
) )
result = self.aider_ignore_spec.match_file(fname) result = self.aider_ignore_spec.match_file(fname)
self.ignore_file_cache[fname] = result self.ignore_file_cache[orig_fname] = result
return result return result
def path_in_repo(self, path): def path_in_repo(self, path):