Skip to content

Commit

Permalink
Change: Adjust next dev version calculation for pre releases
Browse files Browse the repository at this point in the history
When incrementing the version to a dev version after a pre release the
patch/micro version should not be incremented to allow to create another
pre release with the same major.minor.patch version.
  • Loading branch information
bjoernricks committed Mar 1, 2023
1 parent d5e9651 commit acd1e33
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
7 changes: 7 additions & 0 deletions pontos/version/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def next_dev_version(self, current_version: Version) -> Version:
f"{current_version.minor}."
f"{current_version.micro }.dev{current_version.dev + 1}"
)
elif current_version.is_prerelease:
release_version = parse_version(
f"{current_version.major}."
f"{current_version.minor}."
f"{current_version.micro }{current_version.pre[0]}"
f"{current_version.pre[1]}+dev1"
)
else:
release_version = parse_version(
f"{current_version.major}."
Expand Down
12 changes: 6 additions & 6 deletions tests/release/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def test_release_alpha(
):
current_version = Version("0.0.1")
release_version = Version("0.0.2a1")
next_version = Version("0.0.3.dev1")
next_version = Version("0.0.2a1+dev1")
version_command_mock = MagicMock(spec=VersionCommand)
gather_project_mock.return_value = version_command_mock
create_changelog_mock.return_value = "A Changelog"
Expand Down Expand Up @@ -626,7 +626,7 @@ def test_release_alpha(
),
call(
"Automatic adjustments after release\n\n"
"* Update to version 0.0.3.dev1\n",
"* Update to version 0.0.2a1+dev1\n",
verify=False,
gpg_signing_key="123",
),
Expand Down Expand Up @@ -656,7 +656,7 @@ def test_release_beta(
):
current_version = Version("0.0.1")
release_version = Version("0.0.2b1")
next_version = Version("0.0.3.dev1")
next_version = Version("0.0.2b1+dev1")
version_command_mock = MagicMock(spec=VersionCommand)
gather_project_mock.return_value = version_command_mock
create_changelog_mock.return_value = "A Changelog"
Expand Down Expand Up @@ -723,7 +723,7 @@ def test_release_beta(
),
call(
"Automatic adjustments after release\n\n"
"* Update to version 0.0.3.dev1\n",
"* Update to version 0.0.2b1+dev1\n",
verify=False,
gpg_signing_key="123",
),
Expand Down Expand Up @@ -753,7 +753,7 @@ def test_release_release_candidate(
):
current_version = Version("0.0.1")
release_version = Version("0.0.2rc1")
next_version = Version("0.0.3.dev1")
next_version = Version("0.0.2rc1+dev1")
version_command_mock = MagicMock(spec=VersionCommand)
gather_project_mock.return_value = version_command_mock
create_changelog_mock.return_value = "A Changelog"
Expand Down Expand Up @@ -820,7 +820,7 @@ def test_release_release_candidate(
),
call(
"Automatic adjustments after release\n\n"
"* Update to version 0.0.3.dev1\n",
"* Update to version 0.0.2rc1+dev1\n",
verify=False,
gpg_signing_key="123",
),
Expand Down
21 changes: 18 additions & 3 deletions tests/version/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_next_patch_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand All @@ -44,6 +45,7 @@ def test_next_patch_version(self):
"1.2.3",
"1.2.3",
"1.2.3",
"1.2.3",
"22.4.2",
"22.4.1",
"22.4.1",
Expand Down Expand Up @@ -107,6 +109,7 @@ def test_next_minor_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand All @@ -118,6 +121,7 @@ def test_next_minor_version(self):
"1.3.0",
"1.3.0",
"1.3.0",
"1.3.0",
"22.5.0",
"22.5.0",
"22.5.0",
Expand All @@ -141,6 +145,7 @@ def test_next_major_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand All @@ -152,6 +157,7 @@ def test_next_major_version(self):
"2.0.0",
"2.0.0",
"2.0.0",
"2.0.0",
"23.0.0",
"23.0.0",
"23.0.0",
Expand All @@ -175,6 +181,7 @@ def test_next_alpha_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand All @@ -186,6 +193,7 @@ def test_next_alpha_version(self):
"1.2.3a2",
"1.2.4a1",
"1.2.4a1",
"1.2.3a2",
"22.4.2a1",
"22.4.1a1",
"22.4.1a1",
Expand All @@ -209,6 +217,7 @@ def test_next_beta_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand All @@ -220,6 +229,7 @@ def test_next_beta_version(self):
"1.2.3b1",
"1.2.3b2",
"1.2.4b1",
"1.2.3b1",
"22.4.2b1",
"22.4.1b1",
"22.4.1b1",
Expand All @@ -243,6 +253,7 @@ def test_next_release_candidate_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand All @@ -254,6 +265,7 @@ def test_next_release_candidate_version(self):
"1.2.3rc1",
"1.2.3rc1",
"1.2.3rc2",
"1.2.3rc1",
"22.4.2rc1",
"22.4.1rc1",
"22.4.1rc1",
Expand All @@ -277,6 +289,7 @@ def test_next_dev_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand All @@ -285,9 +298,10 @@ def test_next_dev_version(self):
"0.0.2.dev1",
"1.2.4.dev1",
"1.2.4.dev1",
"1.2.4.dev1",
"1.2.4.dev1",
"1.2.4.dev1",
"1.2.3a1+dev1",
"1.2.3b1+dev1",
"1.2.3rc1+dev1",
"1.2.3a1+dev1",
"22.4.2.dev1",
"22.4.1.dev2",
"22.4.1.dev4",
Expand All @@ -311,6 +325,7 @@ def test_parse_version(self):
"1.2.3a1",
"1.2.3b1",
"1.2.3rc1",
"1.2.3a1+dev1",
"22.4.1",
"22.4.1.dev1",
"22.4.1.dev3",
Expand Down

0 comments on commit acd1e33

Please sign in to comment.