bumpversion
bumpversion copied to clipboard
search pattern is disregarded if no matches - dangerous!
Not sure what the rationale for this is. If a search pattern has been specified in the config file, and the pattern is not found, then bumpversion should just not change anything. It should just print an error/warning message and non-zero exit.
file_content_after = file_content_before.replace(
search_for, replace_with
)
if file_content_before == file_content_after:
# TODO expose this to be configurable
file_content_after = file_content_before.replace(
current_version.original,
replace_with,
)
This is causing issues for me as well. Happy to PR, but what exactly is the rationale behind wanting this behavior at all? The comment referenced indicates you'd want it to be a configurable option, which I suppose is fine. But I would argue that the default behavior should definitely be to make no changes to the file.
@mollykarcher2 - I agree with you -- I don't want this behavior at all. (The code block is from this project code, not what I want to be.) What I was saying is that if you have specified a search pattern, and it is not found, the behavior should be non-zero exit, with message indicating the reason. It's dangerous to silently ignore the requested search pattern.
I'd be happy to produce a PR to fix this, but judging from the list of unmerged PRs, it seems like the author is in absentia.
@peritus Could you please indicate if you would be receptive to a PR on this?