Improved performance of find_all_non_ignored_files by not descending into ignored dirs

This commit is contained in:
MischaPanch authored and Michael Panchenko committed 2025-07-24 19:02:33 +02:00
1 parent 2909c67d50
commit 25139d1d74
2 files changed
+5 -3

No files matched your search

+4 -2
View File
@@ -76,8 +76,10 @@ def find_all_non_ignored_files(repo_root: str) -> list[str]:
:return: A list of all non-ignored files in the repository
"""
gitignore_parser = GitignoreParser(repo_root)
_, files = scan_directory(repo_root, recursive=True)
return [file for file in files if not gitignore_parser.should_ignore(file)]
_, files = scan_directory(
repo_root, recursive=True, is_ignored_dir=gitignore_parser.should_ignore, is_ignored_file=gitignore_parser.should_ignore
)
return files
@dataclass
+1 -1
View File
@@ -19,7 +19,7 @@ def iter_subclasses(cls: type[T], recursive: bool = True) -> Generator[type[T],
yield from iter_subclasses(subclass, recursive)
def determine_programming_language_composition(repo_path: str, rel_path_to_gitignore: str = ".gitignore") -> dict[str, float]:
def determine_programming_language_composition(repo_path: str) -> dict[str, float]:
"""
Determine the programming language composition of a repository.