peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 148 forks source link

search pattern is disregarded if no matches - dangerous! #162

Open odoublewen opened 7 years ago

odoublewen commented 7 years ago

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,
            )
mollykarcher2 commented 6 years ago

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.

odoublewen commented 6 years ago

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