diff --git a/aider/watch.py b/aider/watch.py index 34122790c..c810e9ea1 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -17,7 +17,6 @@ def load_gitignores(gitignore_paths: list[Path]) -> Optional[PathSpec]: if not gitignore_paths: return None - # AI: add tests for all of these patterns ai! patterns = [ ".aider*", ".git", diff --git a/tests/basic/test_watch.py b/tests/basic/test_watch.py index 5484934a2..3cfa39264 100644 --- a/tests/basic/test_watch.py +++ b/tests/basic/test_watch.py @@ -4,6 +4,61 @@ from aider.io import InputOutput from aider.watch import FileWatcher +def test_gitignore_patterns(): + """Test that gitignore patterns are properly loaded and matched""" + from pathlib import Path + from aider.watch import load_gitignores + + # Create a temporary gitignore file with test patterns + tmp_gitignore = Path("test.gitignore") + tmp_gitignore.write_text("custom_pattern\n*.custom") + + gitignores = [tmp_gitignore] + spec = load_gitignores(gitignores) + + # Test built-in patterns + assert spec.match_file(".aider.conf") + assert spec.match_file(".git/config") + assert spec.match_file("file~") # Emacs/vim backup + assert spec.match_file("file.bak") + assert spec.match_file("file.swp") + assert spec.match_file("file.swo") + assert spec.match_file("#temp#") # Emacs auto-save + assert spec.match_file(".#lock") # Emacs lock + assert spec.match_file("temp.tmp") + assert spec.match_file("temp.temp") + assert spec.match_file("conflict.orig") + assert spec.match_file("script.pyc") + assert spec.match_file("__pycache__/module.pyc") + assert spec.match_file(".DS_Store") + assert spec.match_file("Thumbs.db") + assert spec.match_file(".idea/workspace.xml") + assert spec.match_file(".vscode/settings.json") + assert spec.match_file("project.sublime-workspace") + assert spec.match_file(".project") + assert spec.match_file(".settings/config.json") + assert spec.match_file("workspace.code-workspace") + assert spec.match_file(".env") + assert spec.match_file(".venv/bin/python") + assert spec.match_file("node_modules/package/index.js") + assert spec.match_file("vendor/lib/module.py") + assert spec.match_file("debug.log") + assert spec.match_file(".cache/files") + assert spec.match_file(".pytest_cache/v/cache") + assert spec.match_file("coverage/lcov.info") + + # Test custom patterns from gitignore file + assert spec.match_file("custom_pattern") + assert spec.match_file("file.custom") + + # Test non-matching patterns + assert not spec.match_file("regular_file.txt") + assert not spec.match_file("src/main.py") + assert not spec.match_file("docs/index.html") + + # Cleanup + tmp_gitignore.unlink() + def test_ai_comment_pattern(): # Create minimal IO and Coder instances for testing class MinimalCoder: