|
9 | 9 | from dataclasses import asdict |
10 | 10 | from glob import glob |
11 | 11 | from io import BytesIO |
12 | | -from pathlib import PurePath |
| 12 | +from pathlib import Path, PurePath |
13 | 13 | from typing import BinaryIO, Dict, List, Tuple, Set, Union, TYPE_CHECKING, Optional |
14 | 14 |
|
15 | 15 | if TYPE_CHECKING: |
@@ -315,15 +315,18 @@ def find_files(self, path: str, ecosystems: Optional[List[str]] = None) -> List[ |
315 | 315 |
|
316 | 316 | for pattern in expanded_patterns: |
317 | 317 | case_insensitive_pattern = Core.to_case_insensitive_regex(pattern) |
318 | | - file_path = os.path.join(path, "**", case_insensitive_pattern) |
319 | | - |
320 | | - log.debug(f"Globbing {file_path}") |
| 318 | + |
| 319 | + log.debug(f"Searching for pattern: {case_insensitive_pattern}") |
321 | 320 | glob_start = time.time() |
322 | | - glob_files = glob(file_path, recursive=True) |
| 321 | + |
| 322 | + # Use pathlib.Path.rglob() instead of glob.glob() to properly match dotfiles/dotdirs |
| 323 | + base_path = Path(path) |
| 324 | + glob_files = base_path.rglob(case_insensitive_pattern) |
323 | 325 |
|
324 | 326 | for glob_file in glob_files: |
325 | | - if os.path.isfile(glob_file) and not Core.is_excluded(glob_file, self.config.excluded_dirs): |
326 | | - files.add(glob_file.replace("\\", "/")) |
| 327 | + glob_file_str = str(glob_file) |
| 328 | + if os.path.isfile(glob_file_str) and not Core.is_excluded(glob_file_str, self.config.excluded_dirs): |
| 329 | + files.add(glob_file_str.replace("\\", "/")) |
327 | 330 |
|
328 | 331 | glob_end = time.time() |
329 | 332 | log.debug(f"Globbing took {glob_end - glob_start:.4f} seconds") |
@@ -414,6 +417,11 @@ def has_manifest_files(self, files: list) -> bool: |
414 | 417 | # Expand brace patterns for each manifest pattern |
415 | 418 | expanded_patterns = Core.expand_brace_pattern(pattern_str) |
416 | 419 | for exp_pat in expanded_patterns: |
| 420 | + # If pattern doesn't contain '/', prepend '**/' to match files in any subdirectory |
| 421 | + # This ensures patterns like '*requirements.txt' match '.test/requirements.txt' |
| 422 | + if '/' not in exp_pat: |
| 423 | + exp_pat = f"**/{exp_pat}" |
| 424 | + |
417 | 425 | for file in norm_files: |
418 | 426 | # Use PurePath.match for glob-like matching |
419 | 427 | if PurePath(file).match(exp_pat): |
|
0 commit comments