Skip to content

Commit

Permalink
Fixes unstable version next breaking version
Browse files Browse the repository at this point in the history
  • Loading branch information
mazinesy committed Sep 16, 2022
1 parent 9124679 commit 570664f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/poetry/core/semver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
30 changes: 30 additions & 0 deletions tests/semver/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 570664f

Please sign in to comment.