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

Bundler package manager: fixes / improvements #717

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions cachi2/core/package_managers/bundler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ def _resolve_bundler_package(
components = [Component(name=name, version=version, purl=main_package_purl.to_string())]
for dep in dependencies:
dep.download_to(deps_dir)
c = Component(name=dep.name, version=dep.version, purl=dep.purl)
if isinstance(dep, GemPlatformSpecificDependency):
c.properties = PropertySet(bundler_package_binary=True).to_properties()
eskultety marked this conversation as resolved.
Show resolved Hide resolved
properties = PropertySet(bundler_package_binary=True).to_properties()
else:
properties = []

c = Component(name=dep.name, version=dep.version, purl=dep.purl, properties=properties)
components.append(c)

return components
Expand Down
6 changes: 3 additions & 3 deletions cachi2/core/package_managers/bundler/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from functools import cached_property
from pathlib import Path
from typing import Annotated, Optional, Union
from urllib.parse import urlparse
from urllib.parse import urljoin, urlparse

import pydantic
from git import Repo
Expand Down Expand Up @@ -71,7 +71,7 @@ def purl(self) -> str:
@cached_property
def remote_location(self) -> str:
"""Return remote location to download this gem from."""
return f"{self.source}/gems/{self.name}-{self.version}.gem"
eskultety marked this conversation as resolved.
Show resolved Hide resolved
return urljoin(self.source, f"downloads/{self.name}-{self.version}.gem")

def download_to(self, deps_dir: RootedPath) -> None:
"""Download represented gem to specified file system location."""
Expand All @@ -93,7 +93,7 @@ class GemPlatformSpecificDependency(GemDependency):
@property
def remote_location(self) -> str:
"""Return remote location to download this gem from."""
return f"{self.source}downloads/{self.name}-{self.version}-{self.platform}.gem"
return urljoin(self.source, f"downloads/{self.name}-{self.version}-{self.platform}.gem")

def download_to(self, deps_dir: RootedPath) -> None:
"""Download represented gem to specified file system location."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@
{
"name": "cachi2:bundler:package:binary",
"value": "true"
},
{
"name": "cachi2:found_by",
"value": "cachi2"
}
],
"purl": "pkg:gem/[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@
{
"name": "cachi2:bundler:package:binary",
"value": "true"
},
{
"name": "cachi2:found_by",
"value": "cachi2"
}
],
"purl": "pkg:gem/[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"generic/archive.zip": "sha256:386428a82f37345fa24b74068e0e79f4c1f2ff38d4f5c106ea14de4a2926e584",
"generic/v1.0.0.zip": "sha256:4fbcaa2a8d17c1f8042578627c122361ab18b7973311e7e9c598696732902f87"
}
{
"generic/archive.zip": "sha256:386428a82f37345fa24b74068e0e79f4c1f2ff38d4f5c106ea14de4a2926e584",
"generic/v1.0.0.zip": "sha256:4fbcaa2a8d17c1f8042578627c122361ab18b7973311e7e9c598696732902f87"
}
2 changes: 1 addition & 1 deletion tests/unit/package_managers/bundler/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_source_gem_dependencies_could_be_downloaded(
) -> None:
base_destination = RootedPath("/tmp/foo")
dependency = GemDependency(name="foo", version="0.0.2", source=source)
expected_source_url = f"{source}/gems/foo-0.0.2.gem"
expected_source_url = f"{source}/downloads/foo-0.0.2.gem"
expected_destination = base_destination.join_within_root(Path("foo-0.0.2.gem"))

dependency.download_to(base_destination)
Expand Down
Loading