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

Revert changes from #115 #136

Merged
merged 3 commits into from
Dec 11, 2023
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
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

0.13.0 (2023-12-08)
-------------------

- Revert changes from
https://github.com/package-url/packageurl-python/pull/115/

0.12.0 (2023-12-08)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = packageurl-python
version = 0.12.0
version = 0.13.0
license = MIT
description = A purl aka. Package URL parser and builder
long_description = file:README.rst
Expand Down
5 changes: 1 addition & 4 deletions src/packageurl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,7 @@ def from_string(cls, purl: str) -> "PackageURL":
ns_name_parts = ns_name.split("/")
ns_name_parts = [seg for seg in ns_name_parts if seg and seg.strip()]
name = ""
if type == "golang":
name = "/".join(ns_name_parts)
namespace = ""
elif not namespace and len(ns_name_parts) > 1:
if not namespace and len(ns_name_parts) > 1:
name = ns_name_parts[-1]
ns = ns_name_parts[0:-1]
namespace = "/".join(ns)
Expand Down
5 changes: 3 additions & 2 deletions src/packageurl/contrib/purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,14 @@ def build_golang_repo_url(purl):
"""
purl_data = PackageURL.from_string(purl)

namespace = purl_data.namespace
name = purl_data.name
version = purl_data.version

if name and version:
return f"https://pkg.go.dev/{name}@{version}"
return f"https://pkg.go.dev/{namespace}/{name}@{version}"
elif name:
return f"https://pkg.go.dev/{name}"
return f"https://pkg.go.dev/{namespace}/{name}"


# Download URLs:
Expand Down
12 changes: 6 additions & 6 deletions tests/data/test-suite-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"purl": "pkg:GOLANG/google.golang.org/genproto#/googleapis/api/annotations/",
"canonical_purl": "pkg:golang/google.golang.org/genproto#googleapis/api/annotations",
"type": "golang",
"namespace": null,
"name": "google.golang.org/genproto",
"namespace": "google.golang.org",
"name": "genproto",
"version": null,
"qualifiers": null,
"subpath": "googleapis/api/annotations",
Expand All @@ -40,8 +40,8 @@
"purl": "pkg:GOLANG/google.golang.org/genproto@abcdedf#/googleapis/api/annotations/",
"canonical_purl": "pkg:golang/google.golang.org/genproto@abcdedf#googleapis/api/annotations",
"type": "golang",
"namespace": null,
"name": "google.golang.org/genproto",
"namespace": "google.golang.org",
"name": "genproto",
"version": "abcdedf",
"qualifiers": null,
"subpath": "googleapis/api/annotations",
Expand All @@ -52,8 +52,8 @@
"purl": "pkg:golang/github.com/nats-io/nats-server/v2/[email protected]",
"canonical_purl": "pkg:golang/github.com/nats-io/nats-server/v2/[email protected]",
"type": "golang",
"namespace": null,
"name": "github.com/nats-io/nats-server/v2/server",
"namespace": "github.com/nats-io/nats-server/v2/",
"name": "server",
"version": "v1.2.9",
"qualifiers": null,
"subpath": null,
Expand Down