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

bump behavior different in command line and python API #79

Closed
YishGene opened this issue Mar 21, 2024 · 4 comments
Closed

bump behavior different in command line and python API #79

YishGene opened this issue Mar 21, 2024 · 4 comments
Labels
question Further information is requested
Milestone

Comments

@YishGene
Copy link

YishGene commented Mar 21, 2024

using dunamai 1.19.2

Say I have a tag 1.3.0 in the current commit with a clean git. Running this:

from dunamai import Version, Pattern
Version.from_any_vcs(Pattern.DefaultUnprefixed).bump().serialize(format="{base}")

produces '1.3.1' (desired: '1.3.0')

command line: dunamai from any --pattern default-unprefixed --format "{base}" --bump correctly produces 1.3.0

Putting the bump inside serialize (emulating what the command line does) produces the correct 1.3.0.

Version.from_any_vcs(Pattern.DefaultUnprefixed).serialize(format="{base}", bump=True)
@mtkennerly mtkennerly added the question Further information is requested label Mar 21, 2024
@mtkennerly
Copy link
Owner

mtkennerly commented Mar 21, 2024

Hi! This is intentional:

  • Version.bump() always bumps and lets you bump by more than 1. This is for cases where you have custom logic/conditions and want more control.
    • bump_version() is the same, but only for the base.
  • Version.serialize(bump=True) only bumps when distance != 0 and only bumps by 1. This is for streamlining the most common case.

The CLI only exposes the latter. I could add a --force-bump/--bump-always option if there's interest, though.

@YishGene
Copy link
Author

YishGene commented Mar 21, 2024 via email

@mtkennerly mtkennerly added this to the v1.20.0 milestone Apr 12, 2024
@mtkennerly
Copy link
Owner

You can now do this in v1.20.0:

Version.from_any_vcs(Pattern.DefaultUnprefixed).bump(smart=True).serialize(format="{base}")

@YishGene
Copy link
Author

Great, thanks for the implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants