diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index e55b798dd..53d0e4051 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -355,6 +355,9 @@ class Coder: for fname in fnames: fname = Path(fname) + if self.repo and self.repo.git_ignored_file(fname): + self.io.tool_warning(f"Skipping {fname} that matches gitignore spec.") + if self.repo and self.repo.ignored_file(fname): self.io.tool_warning(f"Skipping {fname} that matches aiderignore spec.") continue @@ -1779,6 +1782,10 @@ class Coder: self.check_for_dirty_commit(path) return True + if self.repo and self.repo.git_ignored_file(path): + self.io.tool_warning(f"Skipping edits to {path} that matches gitignore spec.") + return + if not Path(full_path).exists(): if not self.io.confirm_ask("Create new file?", subject=path): self.io.tool_output(f"Skipping edits to {path}") diff --git a/aider/commands.py b/aider/commands.py index 91d0ea7c3..524cf7a28 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -737,6 +737,10 @@ class Commands: for matched_file in sorted(all_matched_files): abs_file_path = self.coder.abs_root_path(matched_file) + if self.coder.repo.git_ignored_file(matched_file): + self.io.tool_error(f"Can't add {matched_file} which is in gitignore") + continue + if not abs_file_path.startswith(self.coder.root) and not is_image_file(matched_file): self.io.tool_error( f"Can not add {abs_file_path}, which is not within {self.coder.root}" diff --git a/aider/repo.py b/aider/repo.py index 0b370229f..83cb914de 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -331,6 +331,12 @@ class GitRepo: lines, ) + def git_ignored_file(self, path): + if not self.repo: + return + if self.repo.ignored(path): + return True + def ignored_file(self, fname): self.refresh_aider_ignore()