Migration from bump2version: multiline search/replace not supported
Closed this issue · 3 comments
- bump-my-version version: 0.12.0
- Python version: 3.11.6
- Operating System: linux
Description
We try to migrate from bump2version
to bump-my-version
. Sadly I found out, some of the projects cause bump-my-version
to fail on invalid config. When I investigated the issue, I discovered it's caused by multiline
search and replace
options. In bump2version
a multiline search
/replace
was the way to match more than one line.
MWE
test_file.py
:
# HEADER
__version__ = "0.1.0"
.bumpversion.cfg
:
[bumpversion]
current_version = 0.1.0
[bumpversion:file:test_file.py]
search = # HEADER
__version__ = "{current_version}"
replace = # HEADER
__version__ = "{new_version}"
When I try to use bump-my-version
, I end up with traceback ending with an error
pydantic_core._pydantic_core.ValidationError: 1 validation error for FileConfig
search
Input should be a valid string [type=string_type, input_value=['# HEADER', '__version__ = "{current_version}"'], input_type=list]
For further information visit https://errors.pydantic.dev/2.5/v/string_type
Is it possible to support multiline configuration of search
/replace
to ease the migration from bump2version
?
The docs have multi-line strings examples in both INI and TOML formats, both of which differ from your sample: https://callowayproject.github.io/bump-my-version/reference/search-and-replace-config.html#using-template-strings
@irons I'm aware of that, but in hinders migration from bump2version
. I just don't know whether it's intentional difference or whether it was forgotten.
- The use of
.cfg
configuration is deprecated because it is very difficult to parse reliably. - When I started updating the bump2version code, I included the test cases, and the format you show was not in there.
- Due to the issues of item 1 and what was included in item 2, I'm not going to spend time trying to accommodate edge cases in parsing old configuration values.
I welcome any PRs related to legacy configuration parsing.