mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
feat: Filter top-level directories based on .gitignore in file watcher
This commit is contained in:
parent
d53ee24741
commit
e9097c3b29
1 changed files with 14 additions and 3 deletions
|
@ -115,9 +115,20 @@ class FileWatcher:
|
||||||
|
|
||||||
def watch_files():
|
def watch_files():
|
||||||
try:
|
try:
|
||||||
for changes in watch(
|
# If a gitignore spec exists, filter out top-level entries that match it
|
||||||
str(self.root), watch_filter=self.filter_func, stop_event=self.stop_event
|
if self.gitignore_spec:
|
||||||
):
|
roots_to_watch = [
|
||||||
|
str(path)
|
||||||
|
for path in self.root.iterdir()
|
||||||
|
if not self.gitignore_spec.match_file(path.name)
|
||||||
|
]
|
||||||
|
# Fallback to watching root if all top-level items are filtered out
|
||||||
|
if not roots_to_watch:
|
||||||
|
roots_to_watch = [str(self.root)]
|
||||||
|
else:
|
||||||
|
roots_to_watch = [str(self.root)]
|
||||||
|
|
||||||
|
for changes in watch(*roots_to_watch, watch_filter=self.filter_func, stop_event=self.stop_event):
|
||||||
if not changes:
|
if not changes:
|
||||||
continue
|
continue
|
||||||
changed_files = {str(Path(change[1])) for change in changes}
|
changed_files = {str(Path(change[1])) for change in changes}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue