From b4e827ef637c5de6f33637b5114452eaa1547d85 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 12 Jul 2024 17:13:22 +0100 Subject: [PATCH] Added support for handling absolute paths in the `glob_filtered_to_repo` method. --- aider/commands.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 3fb13f182..b98e1f961 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -394,7 +394,11 @@ class Commands: def glob_filtered_to_repo(self, pattern): try: - raw_matched_files = list(Path(self.coder.root).glob(pattern)) + if os.path.isabs(pattern): + # Handle absolute paths + raw_matched_files = [Path(pattern)] + else: + raw_matched_files = list(Path(self.coder.root).glob(pattern)) except ValueError as err: self.io.tool_error(f"Error matching {pattern}: {err}") raw_matched_files = [] @@ -403,7 +407,11 @@ class Commands: for fn in raw_matched_files: matched_files += expand_subdir(fn) - matched_files = [str(Path(fn).relative_to(self.coder.root)) for fn in matched_files] + matched_files = [ + str(Path(fn).relative_to(self.coder.root)) + for fn in matched_files + if Path(fn).is_relative_to(self.coder.root) + ] # if repo, filter against it if self.coder.repo: