bumpversion icon indicating copy to clipboard operation
bumpversion copied to clipboard

search pattern is disregarded if no matches - dangerous!

Open odoublewen opened this issue 6 years ago • 2 comments

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,
            )

odoublewen avatar Aug 23 '17 04:08 odoublewen

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 avatar Apr 17 '18 20:04 mollykarcher2

@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?

odoublewen avatar Aug 01 '18 17:08 odoublewen