From 0089888cd755764810bce8e021177317c3341891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gon=C3=A7alves?= Date: Tue, 28 Sep 2021 19:00:01 +0200 Subject: [PATCH 1/2] rust2rpm: replace hyphens by underscores in version - fix issue#124 --- rust2rpm/metadata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py index b29e7b5..c0ce530 100644 --- a/rust2rpm/metadata.py +++ b/rust2rpm/metadata.py @@ -75,9 +75,9 @@ class CargoSemVer: version_str = f'{version.major}.{version.minor or 0}' \ f'.{version.patch or 0}' if version.pre_release: - version_str = f'{version_str}{sep}{version.pre_release}' + version_str = f'{version_str}{sep}{version.pre_release.replace("-", "_")}' if version.build: - version_str = f'{version_str}+{version.build}' + version_str = f'{version_str}+{version.build.replace("-", "_")}' return version_str @staticmethod From 6fe36bfafdfe08fe51c76810f75708f064653cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gon=C3=A7alves?= Date: Sun, 10 Oct 2021 14:30:07 +0200 Subject: [PATCH 2/2] Add hyphens to underscores tests --- test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test.py b/test.py index ccda3b5..fabc95f 100644 --- a/test.py +++ b/test.py @@ -78,8 +78,11 @@ def test_parse_version(version, parsed_version): (Version(1, 0, None, None, None), '1.0.0'), (Version(2, 1, 0, None, None), '2.1.0'), (Version(2, 1, 0, None, 'build1'), '2.1.0+build1'), + (Version(2, 1, 0, None, 'snapshot-preview-build1'), '2.1.0+snapshot_preview_build1'), (Version(2, 1, 0, 'alpha1', None), '2.1.0-alpha1'), + (Version(2, 1, 0, 'snapshot-preview-alpha1', None), '2.1.0-snapshot_preview_alpha1'), (Version(2, 1, 0, 'alpha1', 'build1'), '2.1.0-alpha1+build1'), + (Version(2, 1, 0, 'snapshot-preview-alpha1', 'snapshot-preview-build1'), '2.1.0-snapshot_preview_alpha1+snapshot_preview_build1'), ]) def test_unparse_version(parsed_version, version): result = rust2rpm.metadata.CargoSemVer.unparse_version(parsed_version) @@ -89,8 +92,11 @@ def test_unparse_version(parsed_version, version): @pytest.mark.parametrize('parsed_version, version', [ (Version(2, 1, 0, None, None), '2.1.0'), (Version(2, 1, 0, None, 'build1'), '2.1.0+build1'), + (Version(2, 1, 0, None, 'snapshot-preview-build1'), '2.1.0+snapshot_preview_build1'), (Version(2, 1, 0, 'alpha1', None), '2.1.0~alpha1'), + (Version(2, 1, 0, 'snapshot-preview-alpha1', None), '2.1.0~snapshot_preview_alpha1'), (Version(2, 1, 0, 'alpha1', 'build1'), '2.1.0~alpha1+build1'), + (Version(2, 1, 0, 'snapshot-preview-alpha1', 'snapshot-preview-build1'), '2.1.0~snapshot_preview_alpha1+snapshot_preview_build1'), ]) def test_unparse_version_sep(parsed_version, version): result = rust2rpm.metadata.CargoSemVer.unparse_version(