Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy multiline search #118

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bumpversion/config/files_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"filename": section_parts[2],
}
file_options.update(options)
if "search" in file_options and isinstance(file_options["search"], list):
file_options["search"] = "\n".join(file_options["search"])
if "replace" in file_options and isinstance(file_options["replace"], list):
file_options["replace"] = "\n".join(file_options["replace"])
bumpversion_options["files"].append(file_options)
Expand All @@ -66,6 +68,8 @@
"glob": section_parts[2],
}
file_options.update(options)
if "search" in file_options and isinstance(file_options["search"], list):
file_options["search"] = "\n".join(file_options["search"])

Check warning on line 72 in bumpversion/config/files_legacy.py

View check run for this annotation

Codecov / codecov/patch

bumpversion/config/files_legacy.py#L72

Added line #L72 was not covered by tests
if "replace" in file_options and isinstance(file_options["replace"], list):
file_options["replace"] = "\n".join(file_options["replace"])
bumpversion_options["files"].append(file_options)
Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/legacy_multiline_search.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[bumpversion]
current_version = 1.0.0

[bumpversion:file:MULTILINE_SEARCH.md]
search = **unreleased**
**v{current_version}**
replace = **unreleased**
**v{new_version}**
11 changes: 11 additions & 0 deletions tests/fixtures/legacy_multiline_search_expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"current_version": "1.0.0",
"files": [
{
"filename": "MULTILINE_SEARCH.md",
"search": "**unreleased**\n**v{current_version}**",
"replace": "**unreleased**\n**v{new_version}**"
}
],
"parts": {}
}
1 change: 1 addition & 0 deletions tests/test_config/test_files_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def cfg_file(request) -> str:
["conf_file", "expected_file"],
[
param("basic_cfg.cfg", "basic_cfg_expected.json", id="ini basic cfg"),
param("legacy_multiline_search.cfg", "legacy_multiline_search_expected.json", id="multiline search cfg"),
],
)
def test_read_ini_file(conf_file: str, expected_file: str, fixtures_path: Path) -> None:
Expand Down
Loading