monim67 / poetry-bumpversion

Poetry plugin to update __version__ in __init__ file and other files containing version strings
https://pypi.org/project/poetry-bumpversion/
MIT License
81 stars 4 forks source link

Passing multiple files to the plugin for version bumping #1

Closed ohmycaptainnemo closed 1 year ago

ohmycaptainnemo commented 1 year ago

Hi @monim67

Love your work.

Correct me if I am mistaken, but currently, if one would like to bump the version in say two separate files (i.e. file_1.py and file_2.py), one needs to add two code blocks like this:

[tool.poetry_bumpversion.file."file_1.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

[tool.poetry_bumpversion.file."file_2.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

I was hoping we could avoid this repetition and instead of doing what I showed above, we do something like this:

[tool.poetry_bumpversion]
files = ["file_1.py", "file_2.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

What are your thoughts?

monim67 commented 1 year ago

I don't like repeating either. Taking files as array makes a lot sense here. One problem is, the search/replace keywords has to be same for all the files, which might not be the case always.

I'd suggest an extension of your proposition

[[tool.poetry_bumpversion.replacements]]
files = ["file_1.py", "file_2.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

[[tool.poetry_bumpversion.replacements]]
files = ["README.md"]
search = 'version: "{current_version}"'
replace = 'version: "{new_version}"'

This way we can also keep the backward compatibility of tool.poetry_bumpversion.file syntax.

ohmycaptainnemo commented 1 year ago

I don't like repeating either. Taking files as array makes a lot sense here. One problem is, the search/replace keywords has to be same for all the files, which might not be the case always.

I'd suggest an extension of your proposition

[[tool.poetry_bumpversion.replacements]]
files = ["file_1.py", "file_2.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

[[tool.poetry_bumpversion.replacements]]
files = ["README.md"]
search = 'version: "{current_version}"'
replace = 'version: "{new_version}"'

This way we can also keep the backward compatibility of tool.poetry_bumpversion.file syntax.

I see. The search/replace keyword does not have to be the same for all the files. What I mean is that if the search/replace keyword for all the files is the same, then put the files under the same section, like how you have done in the first paragraph of your code above. If the search/replace keywords are not the same, then one can put them in a new section like how you have the README file in the second paragraph. If you think about it realistically, there would not be many practical applications anyways when the user would like to have more than two separate versions to change in a single app.

monim67 commented 1 year ago

This feature is now available in version 0.2.0

ohmycaptainnemo commented 1 year ago

This feature is now available in version 0.2.0

Thank you for the legendary effort.

Just letting you know that version 0.2.0 does not seem to be installable. When I try to install it I get an error saying no versions matching 0.2.0 were found. Also, I think using the new method you introduced, the version in your files always lags behind the pyproject.toml version. However, this was not an issue with the first approach before this change. If you give the new way a go, you should see what I mean. If not, I am happy to elaborate more.

monim67 commented 1 year ago

This version uses the same method as previous version, it just adds a new feature to it. So previous features should work as it was. I can also install it with no issues.

ohmycaptainnemo commented 1 year ago

Thank you.