Open StuartMacKay opened 3 years ago
I suspect this is a bug caused by search
/replace
not using a proper regex replace, but a string replace.
I don't think there's a known workaround at this point...
I should have noted that the [UPDATE]
works but when the order is reversed it has the same problem as reported initially. So to clarify:
[bumpversion:file:docs/conf.py]
search = release = "{current_version}"
replace = release = "{new_version}"
[bumpversion:file:./docs/conf.py]
parse = (?P<major>\d+)\.(?P<minor>\d+)
serialize = {major}.{minor}
search = version = "{current_version}"
replace = version = "{new_version}"
is a valid workaround for this situation.
Related issue: #71.
Kind of reviving because I have run into an analogous problem with release info.
My .bumpversion.cfg
looks something like this:
[bumpversion]
current_version = 0.0.0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<dev>[a-z]+)(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}-{dev}{build}
{major}.{minor}.{patch}
[bumpversion:part:dev]
optional_value = _
first_value = _
values =
_
dev
[bumpversion:part:build]
[bumpversion:file:README.md]
search = v{current_version}
replace = v{new_version}
The top line of my README is:
Package Name (v0.0.0)
I'm getting the following error:
bumpversion.exceptions.VersionNotFoundException: Did not find '(v0.0.0-_0)' in file: 'README.md'
As stated above, it looks like utils.ConfiguredFile.contains
method uses a straight string search rather than a regular expression. I assume there are good reasons not to use regular expressions here. If not, could this be changed to use a regular expression?
NOTE: If I change the config file to the following, it works fine. The problem is that any non-version search components produce the same error.
[bumpversion:part:build]
search = {current_version}
replace = {new_version}
In sphinx's conf.py there are two version numbers:
release
which is the major release version andversion
which is the full version number. For example:To deal with the situation where
version
has a full version number I make the<patch>
group optional when parsing the line. That way it gets restored back to a major release format.When this is run with:
and version contains a full release:
docs/conf.py is updated to the following:
Interestingly, if I switch the order in which the version and release are processed then both lines get mangled:
This only happens if the patch number is present in version, otherwise the optional group in the regex has no ill-effects as long as the version that uses the default regex is processed first.
[UPDATE] You get the same problem by switching the order in which the version numbers are processed: