From dbe1deef70d708e741e80280e9284744b69db3b1 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Sat, 17 May 2025 22:08:12 +0800 Subject: [PATCH] refactor(bump): add type for out, replace function with re escape --- commitizen/bump.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/commitizen/bump.py b/commitizen/bump.py index adfab64cb..1d59eb581 100644 --- a/commitizen/bump.py +++ b/commitizen/bump.py @@ -103,13 +103,13 @@ def files_and_regexs(patterns: list[str], version: str) -> list[tuple[str, str]] """ Resolve all distinct files with their regexp from a list of glob patterns with optional regexp """ - out = [] + out: list[tuple[str, str]] = [] for pattern in patterns: drive, tail = os.path.splitdrive(pattern) path, _, regex = tail.partition(":") filepath = drive + path if not regex: - regex = _version_to_regex(version) + regex = re.escape(version) for path in iglob(filepath): out.append((path, regex)) @@ -138,10 +138,6 @@ def _bump_with_regex( return current_version_found, "".join(lines) -def _version_to_regex(version: str) -> str: - return version.replace(".", r"\.").replace("+", r"\+") - - def create_commit_message( current_version: Version | str, new_version: Version | str,