Skip to content

Commit

Permalink
Fix version parsing for release candidates.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Feb 14, 2024
1 parent 96755ec commit f6f7295
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions kolibri/utils/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ def test_version_file_local_git_version(self, describe_mock, file_mock):
v = get_version((0, 7, 1))
self.assertIn("0.7.1b1.dev0+git.2.gfd48a7a", v)

@mock.patch(
"kolibri.utils.version.get_version_file",
return_value="0.7.1rc1.dev0+git.2.gfd48a7a",
)
@mock.patch("kolibri.utils.version.get_git_describe", return_value=None)
def test_version_file_local_git_version_rc(self, describe_mock, file_mock):
"""
Test that a version file with git describe output is correctly parsed
"""
v = get_version((0, 7, 1))
self.assertIn("0.7.1rc1.dev0+git.2.gfd48a7a", v)

@mock.patch("kolibri.utils.version.get_version_file", return_value="0.1.0a1\n")
@mock.patch("kolibri.utils.version.get_git_describe", return_value=None)
@mock.patch("kolibri.utils.version.get_git_changeset", return_value=None)
Expand Down Expand Up @@ -174,6 +186,16 @@ def test_version_file_overrides(
"""
assert get_version((0, 1, 0)) == "0.1.0b1"

@mock.patch("kolibri.utils.version.get_version_file", return_value="0.1.0rc1")
@mock.patch("kolibri.utils.version.get_git_describe", return_value=None)
@mock.patch("kolibri.utils.version.get_git_changeset", return_value=None)
def test_version_file_rc(self, get_git_changeset_mock, describe_mock, file_mock):
"""
Test that a VERSION specifying a final version will work when the
kolibri.VERSION tuple is consistent.
"""
assert get_version((0, 1, 0)) == "0.1.0rc1"

@mock.patch("kolibri.utils.version.get_version_file", return_value="0.1.0")
@mock.patch("kolibri.utils.version.get_git_describe", return_value=None)
@mock.patch("kolibri.utils.version.get_git_changeset", return_value=None)
Expand Down
2 changes: 1 addition & 1 deletion kolibri/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def normalize_version_to_semver(version):
after = (after or "").strip("-").strip("+").strip(".").split("+")[0]

# split up the alpha/beta letters from the numbers, to sort numerically not alphabetically
after_pieces = re.match(r"([a-z])(\d+)", after)
after_pieces = re.match(r"([a-z]+)(\d+)", after)
if after_pieces:
after = ".".join([piece for piece in after_pieces.group() if piece])

Expand Down

0 comments on commit f6f7295

Please sign in to comment.