From 10f2e114c5be56d2b8b1687006ca5f7abd9515ed Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 18 Oct 2023 10:24:52 -0700 Subject: [PATCH] Added a new parameter `aider_ignore_file` to the `__init__` method of `GitRepo` class and added a new method `filter_ignored_files` to filter files based on gitignore type specs. --- aider/repo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aider/repo.py b/aider/repo.py index 8be07641f..5a472b9c4 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -12,7 +12,7 @@ from .dump import dump # noqa: F401 class GitRepo: repo = None - def __init__(self, io, fnames, git_dname): + def __init__(self, io, fnames, git_dname, aider_ignore_file=None): self.io = io if git_dname: @@ -49,6 +49,8 @@ class GitRepo: self.repo = git.Repo(repo_paths.pop(), odbt=git.GitDB) self.root = utils.safe_abs_path(self.repo.working_tree_dir) + self.aider_ignore_file = aider_ignore_file + def commit(self, fnames=None, context=None, prefix=None, message=None): if not fnames and not self.repo.is_dirty(): return @@ -195,6 +197,12 @@ class GitRepo: return res + def filter_ignored_files(self, fnames): + if not self.aider_ignore_file: + return + + # todo: use pathspec to filter fnames according to the gitignore type specs in self.aider_ignore_file + def path_in_repo(self, path): if not self.repo: return