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

Load cli args before config file #232

Open ecs-jnguyen opened 2 years ago

ecs-jnguyen commented 2 years ago

Description

Hi I'm opening this PR to address this issue: https://github.com/c4urself/bump2version/issues/231

I am modifying the configuration loading piece of bump2version so that the cli arguments take precedence over the configurations in the file.

Behavior before pull request Example

Step 1 create .bumpversion.cfg and version.txt

.bumpversion.cfg

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

[bumpversion:file:version.txt]

version.txt:

0.8.0

Run bump2version

$ bump2version patch --serialize "{major}.{minor}.{patch}" --list
current_version=0.8.0
serialize={major}.{minor}
parse=(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))?
new_version=0.8.1

Results

Behavior after changes

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

[bumpversion:file:version.txt]

version.txt:

0.8.0

Run bump2version

$ bump2version patch --serialize "{major}.{minor}.{patch}" --list
current_version=0.8.0
serialize={major}.{minor}
parse=(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))?
new_version=0.8.1

Results

florisla commented 2 years ago

I think this makes sense... We can consider it for the next release.