peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 148 forks source link

bumpversion skips first entry in list? #167

Open trianta2 opened 6 years ago

trianta2 commented 6 years ago

This is my first time using bumpversion and I can't get a release_name bump to be the first value in a list. My goal is to use bumpversion release_name to go from d.d.d to d.d.d-foo.

Here's my config:

[bumpversion]
current_version = 0.3.9
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release_name>[a-z]+))?
serialize = 
    {major}.{minor}.{patch}-{release_name}
    {major}.{minor}.{patch}

[bumpversion:part:release_name]
first_value = foo
values =
  foo
  bar
  baz

Here's what a dry run looks like:

$ bumpversion --verbose --dry-run --allow-dirty release_name
Would commit to Git with message 'Bump version: 0.3.9 → 0.3.9-bar'

first_value doesn't seem to have any affect.

ionelmc commented 6 years ago

Perhaps a better name for first_value would be default_value.

You can control the first release_name by using --new-version.

arcanefoam commented 6 years ago

First value is the value the part is assigned after a reset not after a bump. A reset happens when you bump any preceding part, that is, bumping minor would cause patch and release_name to be reseted. Also remember that by default the first entry in the values list is treated as an optional value. Since your release_name part is optional (optional regex and alternative serialize) version 0.3.9 is understood by bumpversion as 0.3.9-foo. So bumping release_name will cause foo to increase to bar. Which is the result you get. If you bump patch in 0.3.9 the result should be 0.3.10-foo.

The documentation would benefit from more examples.