Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support processing a file multiple times #111

Closed
florisla opened this issue Jan 6, 2020 · 3 comments · Fixed by #119
Closed

Support processing a file multiple times #111

florisla opened this issue Jan 6, 2020 · 3 comments · Fixed by #119

Comments

@florisla
Copy link
Collaborator

florisla commented Jan 6, 2020

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]
....
florisla added a commit to florisla/bump2version that referenced this issue Jan 11, 2020
So this becomes valid:
[bumpversion:file_myfile_first_pass:version.txt]
[bumpversion:file_myfile_second_pass:version.txt]

Fixes c4urself#111

Inspired by andrivet#3
@c4urself
Copy link
Owner

c4urself commented Jan 12, 2020

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
Copy link
Collaborator Author

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

florisla added a commit to florisla/bump2version that referenced this issue Jan 13, 2020
So this becomes valid:
[bumpversion:file_myfile_first_pass:version.txt]
[bumpversion:file_myfile_second_pass:version.txt]

Fixes c4urself#111

Inspired by andrivet#3
florisla added a commit to florisla/bump2version that referenced this issue Jan 19, 2020
So this becomes valid:
[bumpversion:file_myfile_first_pass:version.txt]
[bumpversion:file_myfile_second_pass:version.txt]

Fixes c4urself#111

Inspired by andrivet#3
@florisla
Copy link
Collaborator Author

Thoughts about the new file(variant) syntax?

florisla added a commit to florisla/bump2version that referenced this issue Mar 1, 2020
So this becomes valid:
[bumpversion:file(first pass):version.txt]
[bumpversion:file(second-pass):version.txt]

Fixes c4urself#111

Inspired by andrivet#3
kutsurak added a commit to MonetDBSolutions/monetdb-stethoscope that referenced this issue May 25, 2020
martinm82 pushed a commit to martinm82/bump2version that referenced this issue Nov 17, 2020
So this becomes valid:
[bumpversion:file(first pass):version.txt]
[bumpversion:file(second-pass):version.txt]

Fixes c4urself#111

Inspired by andrivet#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants