Skip to content

Commit 18dccb4

Browse files
bearomorphismLee-W
authored andcommitted
refactor(bump): add type for out, replace function with re escape
1 parent 50fd65f commit 18dccb4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

commitizen/bump.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ def _files_and_regexes(patterns: list[str], version: str) -> list[tuple[str, str
103103
"""
104104
Resolve all distinct files with their regexp from a list of glob patterns with optional regexp
105105
"""
106-
out = []
106+
out: list[tuple[str, str]] = []
107107
for pattern in patterns:
108108
drive, tail = os.path.splitdrive(pattern)
109109
path, _, regex = tail.partition(":")
110110
filepath = drive + path
111111
if not regex:
112-
regex = _version_to_regex(version)
112+
regex = re.escape(version)
113113

114114
for path in iglob(filepath):
115115
out.append((path, regex))
@@ -140,10 +140,6 @@ def _bump_with_regex(
140140
return current_version_found, "".join(lines)
141141

142142

143-
def _version_to_regex(version: str) -> str:
144-
return version.replace(".", r"\.").replace("+", r"\+")
145-
146-
147143
def create_commit_message(
148144
current_version: Version | str,
149145
new_version: Version | str,

0 commit comments

Comments
 (0)