Skip to content

Commit 278eae5

Browse files
committed
Add support for legacy multiline search options (refs #98)
1 parent 0e84e1c commit 278eae5

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

bumpversion/config/files_legacy.py

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def read_ini_file(file_path: Path) -> Dict[str, Any]: # noqa: C901
5858
"filename": section_parts[2],
5959
}
6060
file_options.update(options)
61+
if "search" in file_options and isinstance(file_options["search"], list):
62+
file_options["search"] = "\n".join(file_options["search"])
6163
if "replace" in file_options and isinstance(file_options["replace"], list):
6264
file_options["replace"] = "\n".join(file_options["replace"])
6365
bumpversion_options["files"].append(file_options)
@@ -66,6 +68,8 @@ def read_ini_file(file_path: Path) -> Dict[str, Any]: # noqa: C901
6668
"glob": section_parts[2],
6769
}
6870
file_options.update(options)
71+
if "search" in file_options and isinstance(file_options["search"], list):
72+
file_options["search"] = "\n".join(file_options["search"])
6973
if "replace" in file_options and isinstance(file_options["replace"], list):
7074
file_options["replace"] = "\n".join(file_options["replace"])
7175
bumpversion_options["files"].append(file_options)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[bumpversion]
2+
current_version = 1.0.0
3+
4+
[bumpversion:file:MULTILINE_SEARCH.md]
5+
search = **unreleased**
6+
**v{current_version}**
7+
replace = **unreleased**
8+
**v{new_version}**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"current_version": "1.0.0",
3+
"files": [
4+
{
5+
"filename": "MULTILINE_SEARCH.md",
6+
"search": "**unreleased**\n**v{current_version}**",
7+
"replace": "**unreleased**\n**v{new_version}**"
8+
}
9+
],
10+
"parts": {}
11+
}

tests/test_config/test_files_legacy.py

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def cfg_file(request) -> str:
3434
["conf_file", "expected_file"],
3535
[
3636
param("basic_cfg.cfg", "basic_cfg_expected.json", id="ini basic cfg"),
37+
param("legacy_multiline_search.cfg", "legacy_multiline_search_expected.json", id="multiline search cfg"),
3738
],
3839
)
3940
def test_read_ini_file(conf_file: str, expected_file: str, fixtures_path: Path) -> None:

0 commit comments

Comments
 (0)