Skip to content

Commit

Permalink
Revert changes from #115 (#136)
Browse files Browse the repository at this point in the history
* Revert changes from #115

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>

* Add CHANGELOG

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>

* Bump version to 0.13.0

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>

---------

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
  • Loading branch information
TG1999 committed Dec 11, 2023
1 parent 9624479 commit 307e4b4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
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/server@v1.2.9",
"canonical_purl": "pkg:golang/github.com/nats-io/nats-server/v2/server@v1.2.9",
"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

0 comments on commit 307e4b4

Please sign in to comment.