c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.06k stars 134 forks source link

bumpversion fails when version is wrapped in quotes #165

Closed sharkvan closed 3 years ago

sharkvan commented 3 years ago

I have several applications that use bumpversion. The latest release has caused a breaking change. I have files like the following

.bumpversion.cfg

bumpversion]
current_version = 1.90.0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
commit = True
tag = True
message = "Bump version: {current_version} → {new_version} [ci skip]"
serialize = 
    {major}.{minor}.{patch}

[bumpversion:file:./version.sh]
search = CONF_VERSION={current_version}
replace = {new_version}

version.sh

CONF_VERSION='1.90.0'

when my build runs bumpversion minor it errors because it cannot find the version in the file version.sh I figured out the it is because the value in wrapped in single quotes. This worked fine in version 1.0.0 but is now broken in 1.0.1

AnumSheraz commented 3 years ago

M also on same boat... here is what I get the error

bumpversion.exceptions.VersionNotFoundException: Did not find '__version__: 0.1.6' in file: '_version.py' ir works fine in v1.0.0

c4urself commented 3 years ago

Thanks for the heads up -- will take a look when I have some more time.

laszewsk commented 3 years ago

I have the same issue with double quotes, I have lots of packages that use this and now its no longer working

laszewsk commented 3 years ago

I just confirmed, bumpversion is no longer usable due to this error. I recommend that users use

bump2version==1.0.0

balrok commented 3 years ago

There was some breaking change. But it is still usable, just change your .bumpversion.cfg to:

[bumpversion:file:./version.sh]
search = CONF_VERSION='{current_version}'
replace = CONF_VERSION='{new_version}'

In my opinion the previous behavior sounds strange.. maybe it did not find the search-string and then did fall back to the default search/replace?

kyluca commented 3 years ago

Yeah I'm with balrok on this one, I also use quotes in my custom search/replace patterns and that works correctly. The previous behaviour was only hiding the fact that the search expression in these examples is incorrect without the quotes, and falling back to the default happened to produce the desired output by coincidence.

This was changed in https://github.com/c4urself/bump2version/pull/128 to fix https://github.com/c4urself/bump2version/issues/127. I believe the current behaviour makes the most sense, a custom replace pattern shouldn't be used on a misconfigured search pattern.

I understand the frustration in updating a dependency and then not having it work as it used to, but I'd still class the change as an intentional bugfix rather than an unintentional breaking change.

Perhaps the best solution here would be to update the documentation with some more examples and a clear instruction for these two scenarios. I'd be happy to submit a PR with some doc changes for Hacktoberfest?

kyluca commented 3 years ago

@c4urself, just pushed #172 to update the docs and clarify what the intended behaviour is here. Please let me know if that's sufficient to close this issue.

Hope that helps the users.

AnumSheraz commented 3 years ago

This seems to be a breaking change, and semantic version for this patch should be 2.0.0

florisla commented 3 years ago

This is indeed a breaking change, but only for configurations which are broken to begin with.

So one could argue if we really need to 'support' such use.

I'm inclined to not call this 2.0.0 since by now the harm is done. Users upgrading to bump2version 1.0 by now will start with 1.0.1 or higher.

florisla commented 3 years ago

@kyluca I'm working on a nicer structure for usage examples in the documentation. I'll ping you when it's ready to accept more examples.

florisla commented 3 years ago

@kyluca I'm working on a nicer structure for usage examples in the documentation. I'll ping you when it's ready to accept more examples.

Nevermind, I forgot about your PR #172

florisla commented 3 years ago

Closing this since it's now better documented and works fine for correct configuration files.

kyluca commented 3 years ago

No worries, thanks! :smile: