Skip to content

Commit bbf4ae0

Browse files
committed
Refactored glob matching to use the wcmatch library
1 parent 420e3bd commit bbf4ae0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

bumpversion/config/utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from __future__ import annotations
44

55
import fnmatch
6-
import glob
76
import re
87
from typing import Dict, List, Pattern
98

9+
from wcmatch import glob
10+
1011
from bumpversion.config.models import FileChange
1112
from bumpversion.exceptions import BumpVersionError
1213
from bumpversion.versioning.models import VersionComponentSpec
@@ -76,10 +77,9 @@ def resolve_glob_files(file_cfg: FileChange) -> List[FileChange]:
7677
A list of resolved file configurations according to the pattern.
7778
"""
7879
files: List[FileChange] = []
79-
exclude_matcher = glob_exclude_pattern(file_cfg.glob_exclude or [])
80-
for filename_glob in glob.glob(file_cfg.glob, recursive=True):
81-
if exclude_matcher.match(filename_glob):
82-
continue
80+
exclude = file_cfg.glob_exclude or []
81+
glob_flags = glob.GLOBSTAR | glob.FORCEUNIX
82+
for filename_glob in glob.glob(file_cfg.glob, flags=glob_flags, exclude=exclude):
8383
new_file_cfg = file_cfg.model_copy()
8484
new_file_cfg.filename = filename_glob
8585
new_file_cfg.glob = None

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies = [
3939
"rich-click",
4040
"rich",
4141
"tomlkit",
42+
"wcmatch>=8.5.1",
4243
]
4344

4445
[project.scripts]

0 commit comments

Comments
 (0)