Skip to content

Commit dd33e2d

Browse files
authored
Capture the whole git tag as the version for GutHub URL in url2purl (#159)
Signed-off-by: tdruez <[email protected]>
1 parent 8fac718 commit dd33e2d

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Changelog
44
0.16.0 (unreleased)
55
-------------------
66

7+
- Capture the whole git tag as the version for GutHub URL in ``url2purl`` instead of
8+
adding a version_prefix qualifier.
9+
Note that the version_prefix qualifier is still supported in ``purl2url`` for
10+
backward compatibility.
11+
712
0.15.4 (2024-07-15)
813
-------------------
914

src/packageurl/contrib/django/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from packageurl import PackageURL
3232
from packageurl.contrib.django.utils import purl_to_lookups
3333

34-
3534
PACKAGE_URL_FIELDS = ("type", "namespace", "name", "version", "qualifiers", "subpath")
3635

3736

src/packageurl/contrib/url2purl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def build_github_api_purl(url):
490490
github_codeload_pattern = (
491491
r"https?://codeload.github.com/(?P<namespace>.+)/(?P<name>.+)/"
492492
r"(zip|tar.gz|tar.bz2|tgz)/(.*/)*"
493-
r"(?P<version_prefix>v|V?)(?P<version>.+)$"
493+
r"(?P<version>.+)$"
494494
)
495495

496496
register_pattern("github", github_codeload_pattern)
@@ -507,20 +507,20 @@ def build_github_purl(url):
507507
r"https?://github.com/(?P<namespace>.+)/(?P<name>.+)"
508508
r"/archive/(.*/)*"
509509
r"((?P=name)(-|_|@))?"
510-
r"(?P<version_prefix>v|V?)(?P<version>.+).(zip|tar.gz|tar.bz2|.tgz)"
510+
r"(?P<version>.+).(zip|tar.gz|tar.bz2|.tgz)"
511511
)
512512

513513
# https://github.com/downloads/mozilla/rhino/rhino1_7R4.zip
514514
download_pattern = (
515515
r"https?://github.com/downloads/(?P<namespace>.+)/(?P<name>.+)/"
516516
r"((?P=name)(-|@)?)?"
517-
r"(?P<version_prefix>v|V?)(?P<version>.+).(zip|tar.gz|tar.bz2|.tgz)"
517+
r"(?P<version>.+).(zip|tar.gz|tar.bz2|.tgz)"
518518
)
519519

520520
# https://github.com/pypa/get-virtualenv/raw/20.0.31/public/virtualenv.pyz
521521
raw_pattern = (
522522
r"https?://github.com/(?P<namespace>.+)/(?P<name>.+)"
523-
r"/raw/(?P<version_prefix>v|V?)(?P<version>[^/]+)/(?P<subpath>.*)$"
523+
r"/raw/(?P<version>[^/]+)/(?P<subpath>.*)$"
524524
)
525525

526526
# https://github.com/fanf2/unifdef/blob/master/unifdef.c
@@ -531,7 +531,7 @@ def build_github_purl(url):
531531

532532
releases_download_pattern = (
533533
r"https?://github.com/(?P<namespace>.+)/(?P<name>.+)"
534-
r"/releases/download/(?P<version_prefix>v|V?)(?P<version>[^/]+)/.*$"
534+
r"/releases/download/(?P<version>[^/]+)/.*$"
535535
)
536536

537537
# https://github.com/pombredanne/schematics.git

tests/contrib/data/url2purl.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,33 +202,33 @@
202202
"https://api.github.com/repos/nexB/scancode-toolkit": "pkg:github/nexb/scancode-toolkit",
203203
"https://api.github.com/repos/nexB/scancode-toolkit/commits/40593af0df6c8378d2b180324b97cb439fa11d66": "pkg:github/nexb/scancode-toolkit@40593af0df6c8378d2b180324b97cb439fa11d66",
204204
"https://codeload.github.com/nexB/scancode-toolkit/tar.gz/3.1.1": "pkg:github/nexb/[email protected]",
205-
"https://codeload.github.com/nexB/scancode-toolkit/tar.gz/v3.1.1": "pkg:github/nexb/scancode-toolkit@3.1.1?version_prefix=v",
205+
"https://codeload.github.com/nexB/scancode-toolkit/tar.gz/v3.1.1": "pkg:github/nexb/scancode-toolkit@v3.1.1",
206206
"https://codeload.github.com/nexB/scancode-toolkit/zip/3.1.1": "pkg:github/nexb/[email protected]",
207-
"https://codeload.github.com/nexB/scancode-toolkit/zip/v3.1.1": "pkg:github/nexb/scancode-toolkit@3.1.1?version_prefix=v",
207+
"https://codeload.github.com/nexB/scancode-toolkit/zip/v3.1.1": "pkg:github/nexb/scancode-toolkit@v3.1.1",
208208
"https://codeload.github.com/nexB/scancode.io/tar.gz/1.0": "pkg:github/nexb/[email protected]",
209-
"https://codeload.github.com/nexB/scancode.io/tar.gz/V1.0": "pkg:github/nexb/scancode.io@1.0?version_prefix=V",
209+
"https://codeload.github.com/nexB/scancode.io/tar.gz/V1.0": "pkg:github/nexb/scancode.io@V1.0",
210210
"https://codeload.github.com/berngp/grails-rest/zip/release/0.7": "pkg:github/berngp/[email protected]",
211211
"https://codeload.github.com/eclipse/m2e-core/zip/releases/1.2/1.2.0.20120903-1050": "pkg:github/eclipse/[email protected]",
212212
"https://github.com/nexB/scancode-toolkit/archive/3.1.1.zip": "pkg:github/nexb/[email protected]",
213-
"https://github.com/nexB/scancode-toolkit/archive/v3.1.1.zip": "pkg:github/nexb/scancode-toolkit@3.1.1?version_prefix=v",
213+
"https://github.com/nexB/scancode-toolkit/archive/v3.1.1.zip": "pkg:github/nexb/scancode-toolkit@v3.1.1",
214214
"https://github.com/pypa/get-virtualenv/raw/20.0.31/public/virtualenv.pyz": "pkg:github/pypa/[email protected]#public/virtualenv.pyz",
215-
"https://github.com/pypa/get-virtualenv/raw/v20.0.31/public/virtualenv.pyz": "pkg:github/pypa/get-virtualenv@20.0.31?version_prefix=v#public/virtualenv.pyz",
215+
"https://github.com/pypa/get-virtualenv/raw/v20.0.31/public/virtualenv.pyz": "pkg:github/pypa/get-virtualenv@v20.0.31#public/virtualenv.pyz",
216216
"https://github.com/fanf2/unifdef/blob/master/unifdef.c": "pkg:github/fanf2/unifdef@master#unifdef.c",
217217
"https://github.com/joebeeson/amazon/blob/master/vendors/aws-sdk/sdk.class.php": "pkg:github/joebeeson/amazon@master#vendors/aws-sdk/sdk.class.php",
218218
"https://github.com/modelfabric/yowl/blob/master/bin/yowl": "pkg:github/modelfabric/yowl@master#bin/yowl",
219-
"https://github.com/syncthing/syncthing/releases/download/v0.14.36/syncthing-source-v0.14.36.tar.gz": "pkg:github/syncthing/syncthing@0.14.36?download_url=https://github.com/syncthing/syncthing/releases/download/v0.14.36/syncthing-source-v0.14.36.tar.gz&version_prefix=v",
220-
"https://github.com/torakiki/pdfsam/releases/download/v3.3.2/pdfsam-3.3.2-bin.zip": "pkg:github/torakiki/pdfsam@3.3.2?download_url=https://github.com/torakiki/pdfsam/releases/download/v3.3.2/pdfsam-3.3.2-bin.zip&version_prefix=v",
221-
"https://github.com/yarnpkg/yarn/releases/download/v1.3.2/yarn-v1.3.2.tar.gz": "pkg:github/yarnpkg/yarn@1.3.2?download_url=https://github.com/yarnpkg/yarn/releases/download/v1.3.2/yarn-v1.3.2.tar.gz&version_prefix=v",
219+
"https://github.com/syncthing/syncthing/releases/download/v0.14.36/syncthing-source-v0.14.36.tar.gz": "pkg:github/syncthing/syncthing@v0.14.36?download_url=https://github.com/syncthing/syncthing/releases/download/v0.14.36/syncthing-source-v0.14.36.tar.gz",
220+
"https://github.com/torakiki/pdfsam/releases/download/v3.3.2/pdfsam-3.3.2-bin.zip": "pkg:github/torakiki/pdfsam@v3.3.2?download_url=https://github.com/torakiki/pdfsam/releases/download/v3.3.2/pdfsam-3.3.2-bin.zip",
221+
"https://github.com/yarnpkg/yarn/releases/download/v1.3.2/yarn-v1.3.2.tar.gz": "pkg:github/yarnpkg/yarn@v1.3.2?download_url=https://github.com/yarnpkg/yarn/releases/download/v1.3.2/yarn-v1.3.2.tar.gz",
222222
"https://github.com/z3APA3A/3proxy/releases/download/0.8.11/3proxy-0.8.11.zip": "pkg:github/z3apa3a/[email protected]?download_url=https://github.com/z3APA3A/3proxy/releases/download/0.8.11/3proxy-0.8.11.zip",
223223
"https://github.com/FasterXML/woodstox/archive/woodstox-core-5.0.2.zip": "pkg:github/fasterxml/[email protected]",
224224
"https://github.com/adobe-fonts/source-code-pro/archive/2.030R-ro/1.050R-it.tar.gz": "pkg:github/adobe-fonts/[email protected]",
225225
"https://github.com/cassandra-rb/simple_uuid/archive/simple_uuid-0.3.0.zip": "pkg:github/cassandra-rb/[email protected]",
226226
"https://github.com/djberg96/sys-filesystem/archive/sys-filesystem-1.1.4.zip": "pkg:github/djberg96/[email protected]",
227227
"https://github.com/freedesktop/xorg-intel-gpu-tools/archive/igt-gpu-tools-1.23.tar.gz": "pkg:github/freedesktop/[email protected]",
228-
"https://github.com/grnet/synnefo/archive/synnefo/v0.12.3.zip": "pkg:github/grnet/synnefo@0.12.3?version_prefix=v",
228+
"https://github.com/grnet/synnefo/archive/synnefo/v0.12.3.zip": "pkg:github/grnet/synnefo@v0.12.3",
229229
"https://github.com/n8n-io/n8n/archive/[email protected]": "pkg:github/n8n-io/[email protected]",
230230
"https://github.com/nginx/nginx/archive/branches/stable-0.7.zip": "pkg:github/nginx/[email protected]",
231-
"https://github.com/swagger-api/swagger-codegen/archive/refs/tags/v3.0.25.tar.gz": "pkg:github/swagger-api/swagger-codegen@3.0.25?version_prefix=v",
231+
"https://github.com/swagger-api/swagger-codegen/archive/refs/tags/v3.0.25.tar.gz": "pkg:github/swagger-api/swagger-codegen@v3.0.25",
232232
"https://github.com/bareos/bareos/archive/Release/16.2.6.zip": "pkg:github/bareos/[email protected]",
233233
"https://github.com/hessu/bchunk/archive/release/1.2.2.tar.gz": "pkg:github/hessu/[email protected]",
234234
"https://github.com/downloads/mozilla/rhino/rhino1_7R4.zip": "pkg:github/mozilla/rhino@1_7R4",

0 commit comments

Comments
 (0)