From 8009bf4c4c912dd2b353b397f6230ea39aa07042 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Mon, 12 Feb 2024 14:52:34 -0700 Subject: [PATCH] allow externally defined parent lockfiles (#26) --- lib/bundler/multilock.rb | 3 ++- spec/bundler/multilock_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/bundler/multilock.rb b/lib/bundler/multilock.rb index 5d56274..d9ec544 100644 --- a/lib/bundler/multilock.rb +++ b/lib/bundler/multilock.rb @@ -70,7 +70,8 @@ def add_lockfile(lockfile = nil, parent = expand_lockfile(parent) if parent != Bundler.default_lockfile(force_original: true) && - !lockfile_definitions.find { |definition| definition[:lockfile] == parent } + !lockfile_definitions.find { |definition| definition[:lockfile] == parent } && + !parent.exist? raise ArgumentError, "Parent lockfile #{parent} is not defined" end diff --git a/spec/bundler/multilock_spec.rb b/spec/bundler/multilock_spec.rb index 271f283..c45ea32 100644 --- a/spec/bundler/multilock_spec.rb +++ b/spec/bundler/multilock_spec.rb @@ -138,6 +138,14 @@ end end + it "allows externally defined parents if they exist" do + with_gemfile(<<~RUBY) do + lockfile("full", parent: Bundler.default_lockfile) + RUBY + invoke_bundler("install") + end + end + it "generates custom lockfiles with varying versions" do with_gemfile(<<~RUBY) do lockfile do