diff --git a/src/poetry/core/semver/version.py b/src/poetry/core/semver/version.py index 2fe6fe873..b7ee59c2e 100644 --- a/src/poetry/core/semver/version.py +++ b/src/poetry/core/semver/version.py @@ -36,12 +36,16 @@ def stable(self) -> Version: def next_breaking(self) -> Version: if self.major == 0: + if self.is_unstable(): + return self.stable.next_patch() + if self.minor is not None and self.minor != 0: return self.next_minor() if self.precision == 1: return self.next_major() elif self.precision == 2: + print(self.is_unstable()) return self.next_minor() return self.next_patch() diff --git a/tests/semver/test_helpers.py b/tests/semver/test_helpers.py index d53e9e57d..f063ac60a 100644 --- a/tests/semver/test_helpers.py +++ b/tests/semver/test_helpers.py @@ -246,6 +246,30 @@ def test_parse_constraint_tilde(input: str, constraint: VersionRange) -> None: Version.from_parts(0, 0, 3), Version.from_parts(0, 0, 4), True ), ), + ( + "^0.0.3-alpha.21", + VersionRange( + Version.from_parts(0, 0, 3, pre=ReleaseTag("alpha", 21)), + Version.from_parts(0, 0, 4), + True, + ), + ), + ( + "^0.1.3-alpha.21", + VersionRange( + Version.from_parts(0, 1, 3, pre=ReleaseTag("alpha", 21)), + Version.from_parts(0, 1, 4), + True, + ), + ), + ( + "^0.0.0-alpha.21", + VersionRange( + Version.from_parts(0, 0, 0, pre=ReleaseTag("alpha", 21)), + Version.from_parts(0, 0, 1), + True, + ), + ), ], ) def test_parse_constraint_caret(input: str, constraint: VersionRange) -> None: @@ -394,6 +418,12 @@ def test_parse_constraints_with_trailing_comma( ("^1", ">=1,<2"), ("^1.0", ">=1.0,<2.0"), ("^1.0.0", ">=1.0.0,<2.0.0"), + ("^1.0.0-alpha.1", ">=1.0.0-alpha.1,<2.0.0"), + ("^0", ">=0,<1"), + ("^0.0", ">=0.0,<0.1"), + ("^0.0.0", ">=0.0.0,<0.0.1"), + ("^0.0.2-alpha.1", ">=0.0.2-alpha.1,<0.0.3"), + ("^0.1.2-alpha.1", ">=0.1.2-alpha.1,<0.1.3"), ("~1", ">=1,<2"), ("~1.0", ">=1.0,<1.1"), ("~1.0.0", ">=1.0.0,<1.1.0"),