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

Add bundler_remote attribute to rb_bundle_fetch #81

Merged
merged 2 commits into from
Feb 26, 2024
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
3 changes: 2 additions & 1 deletion docs/repository_rules.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion ruby/private/bundle_fetch.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ def _rb_bundle_fetch_impl(repository_ctx):
srcs.append(src.name)
repository_ctx.file(src.name, repository_ctx.read(src))

gemfile_lock = parse_gemfile_lock(repository_ctx.read(gemfile_lock_path))
gemfile_lock = parse_gemfile_lock(
repository_ctx.read(gemfile_lock_path),
repository_ctx.attr.bundler_remote,
)
if not versions.is_at_least("2.2.19", gemfile_lock.bundler.version):
fail(_OUTDATED_BUNDLER_ERROR)

Expand Down Expand Up @@ -198,6 +201,10 @@ rb_bundle_fetch = repository_rule(
"env": attr.string_dict(
doc = "Environment variables to use during installation.",
),
"bundler_remote": attr.string(
default = "https://rubygems.org/",
doc = "Remote to fetch the bundler gem from.",
),
"_build_tpl": attr.label(
allow_single_file = True,
default = "@rules_ruby//:ruby/private/bundle_fetch/BUILD.tpl",
Expand Down
5 changes: 3 additions & 2 deletions ruby/private/bundle_fetch/gemfile_lock_parser.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ def _parse_git_package(lines):

return {"revision": revision, "remote": remote}

def parse_gemfile_lock(content):
def parse_gemfile_lock(content, bundler_remote):
"""Parses a Gemfile.lock.
Find lines in the content of a Gemfile.lock that look like package
constraints.
Args:
content: Gemfile.lock contents
bundler_remote: Remote URL for the bundler package.
Returns:
struct with parsed Gemfile.lock
Expand Down Expand Up @@ -180,7 +181,7 @@ def parse_gemfile_lock(content):
version = version,
filename = "bundler-%s.gem" % version,
full_name = "bundler-%s" % version,
remote = "https://rubygems.org/",
remote = bundler_remote,
)
inside_bundled_with = False

Expand Down