Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fall back to original_version if search pattern is not found #127

Closed
florisla opened this issue Jan 26, 2020 · 5 comments · Fixed by #128
Closed

Don't fall back to original_version if search pattern is not found #127

florisla opened this issue Jan 26, 2020 · 5 comments · Fixed by #128

Comments

@florisla
Copy link
Collaborator

florisla commented Jan 26, 2020

This is one of the areas where bump2version does not work like I expect it to.

If for any reason (user error) the search pattern is not found, it simply assumes that it can replace {current_version} with the new version.

This can lead to incorrect changes (broken files!) as demonstrated in #126. I often encounter this while developing search patterns and when using custom replace patterns.

I think this 'fall-back feature' does more harm than good, and we should drop it.

Given a file version.txt

release = "1.0.0"

And a config

[bumpversion]
current_version = 1.0.0

[bumpversion:file:version.txt]
search = current_release = "{current_version}"
replace = current_release = "{new_version}"

Doing bumpversion patch produces this without any warning:

release = "current_release = 1.0.1"

This is wrong!

@sdementen
Copy link

+1

@florisla florisla changed the title Don't fall back to {current_version} if search pattern is not found Don't fall back to original_version if search pattern is not found Jan 27, 2020
@LefterisJP
Copy link

Hey @florisla I am facing the exact same problem for a package-lock.json file and am currently bumping that file's version by hand.

Until your PR is merged and included in a release is there any other way to go around this?

LefterisJP added a commit to LefterisJP/rotkehlchen that referenced this issue Feb 6, 2020
@florisla
Copy link
Collaborator Author

florisla commented Feb 7, 2020

Hi, the problem is that the search expression does not match your package-lock.json file.

This fix does not solve that problem! Instead of producing erratic output, it will simply not bump the version number.

It looks like one can not use whitespace after a newline in the search expression (at least when it's defined in an INI-like config file).

I'm not familiar with a workaround; if you put the advanced expression in parse instead then your current_version and serialize need to be mutilated as well. Not fun.

Unless anyone knows a better option, #48 is what you need.

@LefterisJP
Copy link

I see. Thank you for the response @florisla

Handling of json files would be absolutely great! Any way I can help pushing that PR? 😄

@florisla
Copy link
Collaborator Author

florisla commented Feb 20, 2020

@LefterisJP PR #48 needs to be rebased on master and needs some other impovements. Would be great if you could look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants