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

Add support for premajor, preminor, prepatch, etc. #63

Open
glutanimate opened this issue Feb 20, 2019 · 2 comments
Open

Add support for premajor, preminor, prepatch, etc. #63

glutanimate opened this issue Feb 20, 2019 · 2 comments

Comments

@glutanimate
Copy link

This is inspired by npm's semver increments. To quote the node docs:

premajor in one call will bump the version up to the next major version and down to a prerelease of that major version. preminor, and prepatch work the same way.

E.g.:

$ version
0.3.5
$ bumpversion patch
Bumped from 0.3.5 to 0.3.6
$ bumpversion preminor
Bumped from 0.3.6 to 0.4.0-dev.0

From what I understand it's not possible to replicate this with bumpversion without using --new-version at some point. Either you always walk through the pre-release steps or you don't walk through them at all.

For instance, this config:

[bumpversion]
current_version = 0.3.5
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?(\.(?P<build>\d+))?
serialize = 
    {major}.{minor}.{patch}-{release}.{build}
    {major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = gamma
values = 
    dev
    alpha
    beta
    gamma

would behave as follows:

$ version
0.3.5
$ bumpversion patch
Bumped from 0.3.5 to 0.3.6-dev.0
$ bumpversion minor
Bumped from 0.3.6-dev.0 to 0.4.0-dev.0

In many scenarios this is not desirable, as you would want to be able to push out a patch without having to walk through the pre-release steps (e.g. dev → alpha →...).

The only other option is to add first_value = gamma under [bumpversion:part:release] which would change the behavior as follows:

$ version
0.3.5
$ bumpversion patch
Bumped from 0.3.5 to 0.3.6
$ bumpversion minor
Bumped from 0.3.6 to 0.4.0

But to switch to a pre-release you would then have to use --new-version:

$ bumpversion part --new-version=0.4.0-dev.0
Bumped from 0.3.6 to 0.4.0-dev.0

It would be nice to have a shorthand for this rather than having to manually type the release.

P.S.: Thanks for all your work on bump2version! It's nice to see this project alive and thriving.

@florisla
Copy link
Collaborator

I have a similar flow, with the same inconvenience. The limitation being that you can bump only one part at once unless you specify the full new-version (which is error-prone).

The node semver preminor approach requires the tool to know what is a 'pre' value for a part, which bump2version currently does not know.

I think it would be most flexible if bump2version would support multiple part arguments at once, and also allows you to choose between "bump to the next value like usually" or "bump to the value which I explicitly choose here".

A command-line interface like this would be really sweet:

# specify an explicit value for one specific part
bump2version release=gamma
bump2version --part release=gamma

# bump multiple parts in one go
bump2version --part patch --part release
# bump two parts, with one a specific value
bump2version --part patch --part release=gamma

@c4urself
Copy link
Owner

Definitely open to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants