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

When ignoring the search term, also ignore the replacer. #131

Open luckydonald opened 8 years ago

luckydonald commented 8 years ago
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,
    )

https://github.com/peritus/bumpversion/blob/6ec908f018a827bfae94ed50baf241461eba7bcb/bumpversion/__init__.py#L250

I believe it should replace the unformatted with the unformatted, not the unformatted with the formatted.

if file_content_before == file_content_after:
    # TODO expose this to be configurable
    file_content_after = file_content_before.replace(
        current_version.original,
        new_version.original,
    )

So:

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,
+        new_version.original,
    )