mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
refactor: move gitignores from FileWatcher.start() to constructor
This commit is contained in:
parent
da4cb0aa62
commit
0fedecff58
2 changed files with 6 additions and 6 deletions
|
@ -391,10 +391,9 @@ class InputOutput:
|
||||||
):
|
):
|
||||||
self.rule()
|
self.rule()
|
||||||
|
|
||||||
# ai: the ignores should be passed to FileWater() not start()!
|
|
||||||
self.file_watcher = FileWatcher(root, encoding=self.encoding)
|
|
||||||
gitignore = [str(Path(root) / ".gitignore")]
|
gitignore = [str(Path(root) / ".gitignore")]
|
||||||
self.file_watcher.start(gitignores=gitignore)
|
self.file_watcher = FileWatcher(root, encoding=self.encoding, gitignores=gitignore)
|
||||||
|
self.file_watcher.start()
|
||||||
|
|
||||||
rel_fnames = list(rel_fnames)
|
rel_fnames = list(rel_fnames)
|
||||||
show = ""
|
show = ""
|
||||||
|
|
|
@ -65,7 +65,7 @@ def load_gitignores(gitignore_paths: list[Path]) -> Optional[PathSpec]:
|
||||||
class FileWatcher:
|
class FileWatcher:
|
||||||
"""Watches source files for changes and AI comments"""
|
"""Watches source files for changes and AI comments"""
|
||||||
|
|
||||||
def __init__(self, directory: str, encoding="utf-8"):
|
def __init__(self, directory: str, encoding="utf-8", gitignores: list[str] = None):
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
self.encoding = encoding
|
self.encoding = encoding
|
||||||
self.root = Path(directory)
|
self.root = Path(directory)
|
||||||
|
@ -73,6 +73,7 @@ class FileWatcher:
|
||||||
self.stop_event = None
|
self.stop_event = None
|
||||||
self.watcher_thread = None
|
self.watcher_thread = None
|
||||||
self.changed_files = None
|
self.changed_files = None
|
||||||
|
self.gitignores = gitignores
|
||||||
|
|
||||||
def create_filter_func(self, gitignore_spec, ignore_func):
|
def create_filter_func(self, gitignore_spec, ignore_func):
|
||||||
"""Creates a filter function for the file watcher"""
|
"""Creates a filter function for the file watcher"""
|
||||||
|
@ -115,11 +116,11 @@ class FileWatcher:
|
||||||
|
|
||||||
return filter_func
|
return filter_func
|
||||||
|
|
||||||
def start(self, gitignores: list[str] = None, ignore_func=None):
|
def start(self, ignore_func=None):
|
||||||
"""Start watching for file changes"""
|
"""Start watching for file changes"""
|
||||||
self.stop_event = threading.Event()
|
self.stop_event = threading.Event()
|
||||||
|
|
||||||
gitignore_paths = [Path(g) for g in gitignores] if gitignores else []
|
gitignore_paths = [Path(g) for g in self.gitignores] if self.gitignores else []
|
||||||
gitignore_spec = load_gitignores(gitignore_paths)
|
gitignore_spec = load_gitignores(gitignore_paths)
|
||||||
filter_func = self.create_filter_func(gitignore_spec, ignore_func)
|
filter_func = self.create_filter_func(gitignore_spec, ignore_func)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue