From 78b6e389ee7bba95de540494c7595b37f2885ac7 Mon Sep 17 00:00:00 2001 From: Thomas Druez Date: Mon, 4 Oct 2021 19:40:52 +0400 Subject: [PATCH] Add support for "archive/refs/tags/" github URLs in url2purl #47 Signed-off-by: Thomas Druez --- README.rst | 2 +- src/packageurl/contrib/url2purl.py | 3 ++- tests/contrib/data/url2purl.json | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 06ac7e9..61b8db9 100644 --- a/README.rst +++ b/README.rst @@ -62,7 +62,7 @@ install:: run tests:: - bin/py.test -vvs + bin/py.test tests Make a new release diff --git a/src/packageurl/contrib/url2purl.py b/src/packageurl/contrib/url2purl.py index 1331ee1..0c21453 100644 --- a/src/packageurl/contrib/url2purl.py +++ b/src/packageurl/contrib/url2purl.py @@ -390,7 +390,8 @@ def build_github_purl(url): # https://github.com/nexB/scancode-toolkit/archive/v3.1.1.zip archive_pattern = ( r"https?://github.com/(?P.+)/(?P.+)" - r"/archive/v?(?P.+).(zip|tar.gz|tar.bz2|.tgz)" + r"/archive/(refs/tags/)?" + r"v?(?P.+).(zip|tar.gz|tar.bz2|.tgz)" ) # https://github.com/pypa/get-virtualenv/raw/20.0.31/public/virtualenv.pyz diff --git a/tests/contrib/data/url2purl.json b/tests/contrib/data/url2purl.json index b6596ce..b1d4c77 100644 --- a/tests/contrib/data/url2purl.json +++ b/tests/contrib/data/url2purl.json @@ -211,6 +211,7 @@ "https://github.com/grnet/synnefo/archive/synnefo/v0.12.3.zip": "pkg:github/grnet/synnefo@synnefo/v0.12.3", "https://github.com/n8n-io/n8n/archive/n8n@0.23.0.tar.gz": "pkg:github/n8n-io/n8n@n8n%400.23.0", "https://github.com/nginx/nginx/archive/branches/stable-0.7.zip": "pkg:github/nginx/nginx@branches/stable-0.7", + "https://github.com/swagger-api/swagger-codegen/archive/refs/tags/v3.0.25.tar.gz": "pkg:github/swagger-api/swagger-codegen@3.0.25", "https://bitbucket.org/TG1999/first_repo/src/qa/": "pkg:bitbucket/tg1999/first_repo@qa", "https://bitbucket.org/TG1999/first_repo/src/QA/": "pkg:bitbucket/tg1999/first_repo@QA",