Skip to content

Commit 7f192df

Browse files
committed
fixup! Allow to use ruby_bundle() without Gemfile.lock
1 parent 36893fe commit 7f192df

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

ruby/private/bundle/create_bundle_build_file.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ class BundleBuildFileGenerator
180180
def initialize(workspace_name:,
181181
repo_name:,
182182
build_file: 'BUILD.bazel',
183-
gemfile: 'Gemfile',
183+
gemfile_lock: 'Gemfile.lock',
184184
includes: nil,
185185
excludes: nil,
186186
additional_require_paths: nil)
187187
@workspace_name = workspace_name
188188
@repo_name = repo_name
189189
@build_file = build_file
190-
@gemfile_lock = "#{gemfile}.lock"
190+
@gemfile_lock = gemfile_lock
191191
@includes = includes
192192
@excludes = excludes
193193
# This attribute returns 0 as the third minor version number, which happens to be
@@ -320,14 +320,14 @@ def to_flat_string(array)
320320
# ruby ./create_bundle_build_file.rb "BUILD.bazel" "Gemfile.lock" "repo_name" "{}" "{}" "wsp_name"
321321
if $0 == __FILE__
322322
if ARGV.length != 6
323-
warn("USAGE: #{$0} BUILD.bazel Gemfile repo-name {includes-json} {excludes-json} workspace-name".orange)
323+
warn("USAGE: #{$0} BUILD.bazel Gemfile.lock repo-name {includes-json} {excludes-json} workspace-name".orange)
324324
exit(1)
325325
end
326326

327-
build_file, gemfile, repo_name, includes, excludes, workspace_name, * = *ARGV
327+
build_file, gemfile_lock, repo_name, includes, excludes, workspace_name, * = *ARGV
328328

329329
BundleBuildFileGenerator.new(build_file: build_file,
330-
gemfile: gemfile,
330+
gemfile_lock: gemfile_lock,
331331
repo_name: repo_name,
332332
includes: JSON.parse(includes),
333333
excludes: JSON.parse(excludes),

ruby/private/bundle/def.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ def bundle_install(runtime_ctx, previous_result):
137137
return result
138138

139139
def generate_bundle_build_file(runtime_ctx, previous_result):
140+
if runtime_ctx.ctx.attr.gemfile_lock:
141+
gemfile_lock = runtime_ctx.ctx.attr.gemfile_lock.name
142+
else:
143+
gemfile_lock = "{}.lock".format(runtime_ctx.ctx.attr.gemfile.name)
144+
140145
# Create the BUILD file to expose the gems to the WORKSPACE
141146
# USAGE: ./create_bundle_build_file.rb BUILD.bazel Gemfile.lock repo-name [excludes-json] workspace-name
142147
args = [
@@ -146,7 +151,7 @@ def generate_bundle_build_file(runtime_ctx, previous_result):
146151
"bundler/lib",
147152
SCRIPT_BUILD_FILE_GENERATOR, # The template used to created bundle file
148153
"BUILD.bazel", # Bazel build file (can be empty)
149-
runtime_ctx.ctx.attr.gemfile.name, # Gemfile -> Gemfile.lock where we list all direct and transitive dependencies
154+
gemfile_lock, # Gemfile.lock where we list all direct and transitive dependencies
150155
runtime_ctx.ctx.name, # Name of the target
151156
repr(runtime_ctx.ctx.attr.includes),
152157
repr(runtime_ctx.ctx.attr.excludes),

0 commit comments

Comments
 (0)