Skip to content

Commit

Permalink
Refactored glob matching to use the wcmatch library
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed May 1, 2024
1 parent 420e3bd commit bbf4ae0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bumpversion/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from __future__ import annotations

import fnmatch
import glob
import re
from typing import Dict, List, Pattern

from wcmatch import glob

from bumpversion.config.models import FileChange
from bumpversion.exceptions import BumpVersionError
from bumpversion.versioning.models import VersionComponentSpec
Expand Down Expand Up @@ -76,10 +77,9 @@ def resolve_glob_files(file_cfg: FileChange) -> List[FileChange]:
A list of resolved file configurations according to the pattern.
"""
files: List[FileChange] = []
exclude_matcher = glob_exclude_pattern(file_cfg.glob_exclude or [])
for filename_glob in glob.glob(file_cfg.glob, recursive=True):
if exclude_matcher.match(filename_glob):
continue
exclude = file_cfg.glob_exclude or []
glob_flags = glob.GLOBSTAR | glob.FORCEUNIX
for filename_glob in glob.glob(file_cfg.glob, flags=glob_flags, exclude=exclude):
new_file_cfg = file_cfg.model_copy()
new_file_cfg.filename = filename_glob
new_file_cfg.glob = None
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies = [
"rich-click",
"rich",
"tomlkit",
"wcmatch>=8.5.1",
]

[project.scripts]
Expand Down

0 comments on commit bbf4ae0

Please sign in to comment.