fix: Handle ValueError when getting relative path in ignored_file_raw

This commit is contained in:
Paul Gauthier 2024-09-23 11:41:28 -07:00 committed by Paul Gauthier (aider)
parent 1fe2be4633
commit 8f583ca119

View file

@ -344,7 +344,13 @@ class GitRepo:
def ignored_file_raw(self, fname): def ignored_file_raw(self, fname):
if self.subtree_only: if self.subtree_only:
fname_path = Path(self.normalize_path(fname)) fname_path = Path(self.normalize_path(fname))
cwd_path = Path.cwd().resolve().relative_to(Path(self.root).resolve()) try:
cwd_path = Path.cwd().resolve().relative_to(Path(self.root).resolve())
except ValueError:
# Issue #1524
# ValueError: 'C:\\dev\\squid-certbot' is not in the subpath of 'C:\\dev\\squid-certbot
# Clearly, fname is not under cwd... so ignore it
return True
if cwd_path not in fname_path.parents and fname_path != cwd_path: if cwd_path not in fname_path.parents and fname_path != cwd_path:
return True return True