mirror of
https://github.com/tiennm99/serena.git
synced 2026-08-24 02:25:54 +00:00
Merge pull request #349 from oraios/improve_search_for_nonignored_files
Improved performance of find_all_non_ignored_files
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user