c4urself / bump2version

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

Support processing a file multiple times #111

Closed florisla closed 4 years ago

florisla commented 4 years ago

For a certain file I needed to have two different serializations.

Turns out you can do that using bumpversion.cfg as long as the file name is written differently each time. I'm using a ./ prefix here.

[bumpversion:file:version.txt]
search = Version: {current_version}
replace = Version: {new_version}
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize = {major}.{minor}.{patch}

[bumpversion:file:./version.txt]
search = Release: {current_version}
replace= Release: {new_version}
parse = (?P<major>\d+)-(?P<minor>\d+)-(?P<patch>\d+)
serialize = {major}-{minor}-{patch}

Is this something we should document? I think this can solve #43 and #4, although it's perhaps not a very intuitive solution for those issues.

Thought: we could extend the [bumpversion:file] syntax to support multiple editions to make this more readable, like

[bumpversion:file:version.txt:version]
...
[bumpversion:file:version.txt:release]
....
c4urself commented 4 years ago

There's a Helm question on this as well, in general it feels like a bit of a code smell if you have multiple variables that reference a version in a single file and so I think it makes sense to make it a duplicate action in the .bumpversion.cfg as well; that is, have multiple sections for each time you want to search/replace in the same file.

florisla commented 4 years ago

I'll rebase once the Python 2.7 drop is merged.

florisla commented 4 years ago

Thoughts about the new file(variant) syntax?