Avoid incorrect replacements
In files that have multiple version strings, Bump My Version may find the wrong string and replace it. Given this requirements.txt for MyProject:
text
Django>=1.5.6,<1.6
MyProject==1.5.6The default search and replace templates will replace the wrong text. Instead of changing MyProject's version from 1.5.6 to 1.6.0, it changes Django's version:
text
Django>=1.6.0,<1.6
MyProject==1.5.6Providing search and replace templates for the requirements.txt file will avoid this.
This .bumpversion.toml will ensure only the line containing MyProject will be changed:
toml
[tool.bumpversion]
current_version = "1.5.6"
[[tool.bumpversion.files]]
filename = "requirements.txt"
search = "MyProject=={current_version}"
replace = "MyProject=={new_version}"If the string to be replaced includes literal quotes, the search and replace patterns must include them to match. Given the file version.sh:
text
MY_VERSION="1.2.3"Then the following search and replace patterns (including quotes) would be required:
toml
[[tool.bumpversion.files]]
filename = "version.sh"
search = "MY_VERSION=\"{current_version}\""
replace = "MY_VERSION=\"{new_version}\""