Skip to content

Commit dbe1dee

Browse files
committed
refactor(bump): add type for out, replace function with re escape
1 parent a0cc490 commit dbe1dee

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_regexs(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))
@@ -138,10 +138,6 @@ def _bump_with_regex(
138138
return current_version_found, "".join(lines)
139139

140140

141-
def _version_to_regex(version: str) -> str:
142-
return version.replace(".", r"\.").replace("+", r"\+")
143-
144-
145141
def create_commit_message(
146142
current_version: Version | str,
147143
new_version: Version | str,

0 commit comments

Comments
 (0)