Skip to content

Commit

Permalink
Fix spec file detection in current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
KSmanis committed May 29, 2021
1 parent a7ad392 commit 75ad67f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pipautocompile/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import tempfile
from itertools import groupby
from pathlib import Path
from typing import Iterable, List, Tuple, Union
from typing import Iterable, Iterator, Tuple, Union

import click

Expand Down Expand Up @@ -34,8 +34,10 @@ def _find_spec_files(
"**/requirements.in",
"**/requirements/*.in",
),
) -> List[Path]:
return sorted(s for p in patterns for s in Path(path).glob(p) if s.is_file())
) -> Iterator[Path]:
for s in Path(path).rglob("*.in"):
if s.is_file() and any(s.resolve(strict=True).match(p) for p in patterns):
yield s


def _file_contains_regex(
Expand Down Expand Up @@ -103,7 +105,7 @@ def cli(
pip_compile_args = DEFAULT_PIP_COMPILE_ARGS

initial_working_tree = _working_tree()
for spec_dir, specs in groupby(_find_spec_files(), key=lambda spec: spec.parent):
for spec_dir, specs in groupby(sorted(_find_spec_files()), key=lambda s: s.parent):
if not recurse_submodules and initial_working_tree != _working_tree(spec_dir):
continue

Expand Down

0 comments on commit 75ad67f

Please sign in to comment.