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

Added 'dev' as a version bump rule to increment versions with .devM #8719

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gaileyleseman
Copy link

This adds dev as a version bump rule for developmental releases. This was already implemented in poetry-core, I've just added the option to the cli.

This is my first contribution, I hope I followed the correct procedure!

Pull Request Check List

Resolves: #8718

  • Added tests for changed code.
  • Updated documentation for changed code.

@@ -46,6 +46,9 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
("1.2.3beta1", "prerelease", "1.2.3b2"),
("1.2.3b1", "prerelease", "1.2.3b2"),
("1.2.3", "prerelease", "1.2.4a0"),
("1.2.3", "dev", "1.2.3.dev0"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is actually what it is doing then it is bugged, because the dev release is earlier than the non-dev release

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, thanks! I was (wrongly) treating the .devM similar as the .postM releases.
That makes the problem more ambiguous and that also explains this warning in poetry-core.

            warnings.warn(
                "Calling next_devrelease() on a non dev release is deprecated for"
                " its ambiguity. Use next_major(), next_minor(), etc. together with"
                " first_devrelease()",
                DeprecationWarning,
                stacklevel=2,
            )

I see the following options:

  1. Always do a prerelease before adding .dev
        elif rule == "dev":
            if parsed.is_stable():
                new = self.increment_version(version, "prerelease", next_phase)
            new = parsed.next_devrelease()
  1. Raise a ValueError when trying to increment with dev on a stable version
        elif rule == "dev":
            if parsed.is_stable():
                raise ValueError(
                    "Cannot use the 'dev' bump rule on a stable version because"
                    " the behavior is ambiguous. Please use 'premajor', 'preminor', "
                    " 'prepatch' or 'prerelease' first to indicate the next version"
                )
            new = parsed.next_devrelease()
  1. If both options above are insufficient, close this MR and keep doing the .devM increments manually
❯poetry version --short 
1.8.0.dev0
❯ poetry version "1.8.0.dev1"
Bumping version from 1.8.0.dev0 to 1.8.0.dev1

Let me know what you think!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don''t really mind what the resolution is - my personal practice is to edit the pyproject.toml directly: I don't find that poetry version is valuable enough to be worth the code, and so from my point of view this all is very niche.

However I do think that if the CLI ends up moving the version number backwards, where all of the other similar commands move it forwards - then that'll generate more bug reports than it fixes!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I'm experimenting with automatically bumping versions through ci/cd pipelines, for which the poetry version command could be very useful.

I've updated the logic and the docs/tests such that the version number always moves forward.

Copy link
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I think we should define the target behavior in #8718 first because it's ambigious. For example, we could also bump 1.0.2 to 1.0.3.dev0 instead of 1.0.3a0.dev0. (Both are correct.)

Comment on lines +705 to +706
| dev | 1.1.0a0 | 1.1.0a0.dev0 |
| dev | 1.0.2a0 | 1.0.2a0.dev0 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a decrement. (1.1.0a0.dev0 comes before 1.1.0a0.)

Comment on lines +133 to +134
else:
new = parsed.first_devrelease()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a decrement.

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

Successfully merging this pull request may close these issues.

Add 'dev' as version bump rule for developmental releases.
3 participants