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

Fix version parsing for release candidates. #11872

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]{1,2})(\d+)", after)
if after_pieces:
after = ".".join([piece for piece in after_pieces.group() if piece])

Expand Down
Loading