peritus / bumpversion

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

Issue while using search and replace configurations. #202

Open mss30 opened 5 years ago

mss30 commented 5 years ago

Thanks for replying. I'd tried to add search and replace options but these don't work as expected.

Here is my .bumpversion.cfg file: [bumpversion] current_version = 0.2.2

[bumpversion:file:setup.py]
search = version='{current_version}',
replace = version='{new_version}',

And here is the setup.py when I run the bumpversion command:

from setuptools import setup, find_packages

setup(
    name='my-pack',
    version='0.2.3',
    packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
    install_requires=[
        'someotherpackage==version='0.2.3',',
    ],
)

It would be great if you can help me in this problem.

Originally posted by @mss30 in https://github.com/peritus/bumpversion/issues/201#issuecomment-484487322

jawahar273 commented 5 years ago

It is best to remove quotes in .bumpversion.cfg and it run

[bumpversion:file:setup.py]
search = version={current_version},
replace = version={new_version},
jlejeune commented 3 years ago

I had the same issue using the same bumpversion config file and after using pdb to understand why this is happening, I realized that the _replace_version_in_files() function was called two times on the same setup.py file. It was because I used the command : bumpversion minor setup.py but no need to specify setup.py as positional argument because it's already specified in bumpversion config file. I don't really understand why on the second run it updated the dependency version but by running only that command bumpversion minor it does the trick.