Skip to content

Commit 8638512

Browse files
committed
fix: version update in a docker-compose.yaml file
1 parent 8a35457 commit 8638512

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

commitizen/bump.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _get_line_break_position(text: str) -> int:
205205

206206
def _version_to_regex(version: str):
207207
clean_regex = version.replace(".", r"\.").replace("+", r"\+")
208-
return re.compile(f"\\b{clean_regex}\\b")
208+
return re.compile(f"{clean_regex}")
209209

210210

211211
def create_tag(version: Union[Version, str], tag_format: Optional[str] = None):

tests/test_bump_update_version_in_files.py

+28-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@
5050
version = "1.2.3"
5151
"""
5252

53+
DOCKER_COMPOSE = """
54+
version: "3.3"
55+
56+
services:
57+
app:
58+
image: my-repo/my-container:v1.2.3
59+
command: my-command
60+
"""
61+
5362
MULTIPLE_VERSIONS_INCREASE_STRING = 'version = "1.2.9"\n' * 30
5463
MULTIPLE_VERSIONS_REDUCE_STRING = 'version = "1.2.10"\n' * 30
5564

@@ -104,8 +113,25 @@ def multiple_versions_reduce_string(tmpdir):
104113

105114

106115
@pytest.fixture(scope="function")
107-
def version_files(commitizen_config_file, python_version_file, version_repeated_file):
108-
return [commitizen_config_file, python_version_file, version_repeated_file]
116+
def docker_compose_file(tmpdir):
117+
tmp_file = tmpdir.join("docker-compose.yaml")
118+
tmp_file.write(DOCKER_COMPOSE)
119+
return str(tmp_file)
120+
121+
122+
@pytest.fixture(scope="function")
123+
def version_files(
124+
commitizen_config_file,
125+
python_version_file,
126+
version_repeated_file,
127+
docker_compose_file,
128+
):
129+
return [
130+
commitizen_config_file,
131+
python_version_file,
132+
version_repeated_file,
133+
docker_compose_file,
134+
]
109135

110136

111137
def test_update_version_in_files(version_files):

0 commit comments

Comments
 (0)