Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/scmrepo/git/lfs/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,13 @@ def _collect_objects(
def _filter_paths(
paths: Iterable[str], include: Optional[list[str]], exclude: Optional[list[str]]
) -> Iterator[str]:
filtered = set()
if include:
for pattern in include:
filtered.update(fnmatch.filter(paths, pattern))
else:
filtered.update(paths)
include_match = re.compile(r"|".join(map(fnmatch.translate, include))).match
paths = (path for path in paths if include_match(path) is not None)
if exclude:
for pattern in exclude:
filtered.difference_update(fnmatch.filter(paths, pattern))
yield from filtered
exclude_match = re.compile(r"|".join(map(fnmatch.translate, exclude))).match
paths = (path for path in paths if exclude_match(path) is None)
yield from paths


if __name__ == "__main__":
Expand Down