Skip to content

Commit

Permalink
Added caching to the resolved filemap
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Dec 15, 2023
1 parent 89686b8 commit c96e0bd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bumpversion/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Config(BaseSettings):
included_paths: List[str] = Field(default_factory=list)
excluded_paths: List[str] = Field(default_factory=list)
model_config = SettingsConfigDict(env_prefix="bumpversion_")
_resolved_filemap: Optional[Dict[str, List[FileChange]]] = None

def add_files(self, filename: Union[str, List[str]]) -> None:
"""Add a filename to the list of files."""
Expand All @@ -122,6 +123,12 @@ def add_files(self, filename: Union[str, List[str]]) -> None:

@property
def resolved_filemap(self) -> Dict[str, List[FileChange]]:
"""Return the cached resolved filemap."""
if self._resolved_filemap is None:
self._resolved_filemap = self._resolve_filemap()
return self._resolved_filemap

def _resolve_filemap(self) -> Dict[str, List[FileChange]]:
"""Return a map of filenames to file configs, expanding any globs."""
from bumpversion.config.utils import resolve_glob_files

Expand Down

0 comments on commit c96e0bd

Please sign in to comment.