Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/fetchcode/package_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ def _get_github_packages(purl, version_regex, ignored_tag_regex, default_package
else:
version = tag

version = version.strip("Vv").strip()
version = version.strip().lstrip("Vv")
if "+" in version:
first, last = version.split("+")
first.replace("_", ".")
first = first.replace("_", ".")
version = f"{first}+{last}"
Comment thread
codewithfourtix marked this conversation as resolved.
Outdated
else:
version = version.replace("_", ".")
Expand Down
22 changes: 22 additions & 0 deletions tests/test_github_tag_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import datetime
Comment thread
codewithfourtix marked this conversation as resolved.

import pytest
from packageurl import PackageURL

from fetchcode import package_util
from fetchcode.packagedcode_models import Package


@pytest.mark.parametrize(
"tag,expected", [("v1.2-dev", "1.2-dev"), ("v1_2_3+build_4", "1.2.3+build_4")]
)
def test_github_tag_version_normalization(monkeypatch, tag, expected):
monkeypatch.setattr(
package_util.utils,
"fetch_github_tags_gql",
lambda purl: [(tag, datetime.datetime(2026, 1, 1))],
)
purl = PackageURL("github", "example", "project")
packages = list(package_util.get_github_packages(purl, None, None, Package(**purl.to_dict())))
assert packages[0].version == expected
assert packages[0].download_url.endswith(f"/{tag}.tar.gz")