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

Build result in 0.0.0-01 instead of 0.0.0-dev1 #134

Open RonZhang724 opened 4 years ago

RonZhang724 commented 4 years ago

I have the following .bumpversion.cfg: whenever I run bump2version build, the new_version becomes 0.0.0-01 Is there a way for the first build to become 0.0.0-dev1?

[bumpversion]
current_version = 0.0.0
commit = True
tag = False
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 = prod
first_value = dev
values =
    dev
    prod

[bumpversion:part:build]
mtusseau commented 3 years ago

Hi, same problem here. I tried to setup a release-candidate workflow:

[bumpversion]
current_version = 2.0.0-rc1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>rc)(?P<rc>\d+))?
serialize = 
    {major}.{minor}.{patch}-{release}{rc}
        {major}.{minor}.{patch}-rc{rc}
    {major}.{minor}.{patch}
[bumpversion:part:release]
optional_value = release
first_value = rc
values = 
    rc
    release

Your build part is my rc part. Seems it works since:

bump2version rc --list --dry-run --current-version 2.0.0 --allow-dirty
   new_version = 2.0.0-rc1
bump2version rc --list --dry-run --current-version 2.0.0-rc1 --allow-dirty
   new_version = 2.0.0-rc2
bump2version release --list --dry-run --current-version 2.0.0-rc1 --allow-dirty
   new_version = 2.0.0
bump2version release --list --dry-run --current-version 2.0.0 --allow-dirty
   ValueError: The part has already the maximum value among ['rc', 'release'] and cannot be bumped.

Hope this will help.

andersonbrands commented 3 years ago

Hi, @RonZhang724 , I guess 0.0.0 translates to 0.0.0-prod0 which is greater than 0.0.0-dev1, hence "going up" here wouldn't make sense.

I believe bump2version build over 0.0.0-prod0 would produce 0.0.0-prod1, not sure why you got this leading zero in 0.0.0-01, maybe it has to do with prod being optional.

Hi, @mtusseau, in your case 2.0.0 would translate to 2.0.0-release0 so when you try to bump2version release over 2.0.0-release0 the word release is already the max value for the release part, so that you are not able to bump it. You can only bump2version release over a "cr release".

florisla commented 3 years ago

@RonZhang724 It's true that you can't go from 0.0.0 (with release being prod) to 0.0.0-dev1.

It's definitely a bug that 0.0.0-prod1 shows up as 0.0.0-01.