diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e80195..89c1b19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Status of the `main` branch. Changes prior to the next official version change will appear here. +Fixes: +* Ignore `.git` in check for ignored paths and improve performance of `find_all_non_ignored_files` + # 0.1.3 ## Summary diff --git a/src/serena/util/file_system.py b/src/serena/util/file_system.py index e4195ae..327a223 100644 --- a/src/serena/util/file_system.py +++ b/src/serena/util/file_system.py @@ -3,6 +3,7 @@ import logging import os from collections.abc import Callable from dataclasses import dataclass, field +from pathlib import Path from typing import NamedTuple import pathspec @@ -76,8 +77,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 @@ -256,6 +259,11 @@ class GitignoreParser: else: rel_path = path + # Ignore paths inside .git + rel_path_first_path = Path(rel_path).parts[0] + if rel_path_first_path == ".git": + return True + abs_path = os.path.join(self.repo_root, rel_path) # Normalize path separators diff --git a/src/serena/util/inspection.py b/src/serena/util/inspection.py index 4a859c1..668cf54 100644 --- a/src/serena/util/inspection.py +++ b/src/serena/util/inspection.py @@ -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.