Skip to content

Commit

Permalink
Switch to bundler_remote
Browse files Browse the repository at this point in the history
  • Loading branch information
sushain97 committed Feb 25, 2024
1 parent 4be4361 commit c2cd0be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
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 = remote,
remote = bundler_remote,
)
inside_bundled_with = False

Expand Down

0 comments on commit c2cd0be

Please sign in to comment.