c4urself / bump2version

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

It is possible to get version-release from multiple lines (rpm spec)? #43

Open vooon opened 5 years ago

vooon commented 5 years ago

I want to also bump release number of spec file, but it was on separate line. e.g.

Version: 0.5.0
Release: 1{?%dist}

My .bumpversion.cfg

[bumpversion]
current_version = 0.5.0
commit = True
tag = True

[bumpversion:file:mysrv/__init__.py]

[bumpversion:file:spec/mysrv.spec]
c4urself commented 5 years ago

Hmm, that would require a re.MULTILINE regex matching, maybe try a local dev version and change this line: https://github.com/c4urself/bump2version/blob/master/bumpversion/version_part.py#L137 to see if it works and send a PR?

florisla commented 4 years ago

Perhaps you can work around this limitation using a trick.

Version-bump the file twice -- which you can do as long as the INI headers are not identical, e.g. if the file name is written differently the second time.

Employ different parse, serialize, search and replace like this:

[bumpversion]
current_version = 0.5.0.1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+).(?P<build>\d+)
serialize = {major}.{minor}.{patch}.{build}

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

[bumpversion:file:./rpm.spec]
search = Release: {current_version}
replace= Release: {new_version}
parse = (?P<build>\d+)
serialize = {build}