diff options
author | David RodrÃguez <[email protected]> | 2024-09-20 20:01:13 +0200 |
---|---|---|
committer | git <[email protected]> | 2024-09-24 14:17:23 +0000 |
commit | b48add3c65c394b2314eb699441f1a1c27b3c2c0 (patch) | |
tree | eedb451644c247f3cca5caf7608d5c6284c76fde | |
parent | 07842491c539bf5d0abe29d63380ee5aaf121934 (diff) |
[rubygems/rubygems] Fix `bundler/inline` overwriting lockfiles
This was introduced by https://github.com/rubygems/rubygems/commit/0b7be7bb7705, because
the original patch was not adapted to some recent refactorings.
https://github.com/rubygems/rubygems/commit/0bca60d6e5
Co-authored-by: Hiroshi SHIBATA <[email protected]>
-rw-r--r-- | lib/bundler/definition.rb | 2 | ||||
-rw-r--r-- | spec/bundler/runtime/inline_spec.rb | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 75eb5ffa1b..e7e6c49e6c 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -317,7 +317,7 @@ module Bundler def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false) if [true, false, nil].include?(file_or_preserve_unknown_sections) - target_lockfile = lockfile || Bundler.default_lockfile + target_lockfile = lockfile preserve_unknown_sections = file_or_preserve_unknown_sections else target_lockfile = file_or_preserve_unknown_sections diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb index 2deda75509..5ff555ab0d 100644 --- a/spec/bundler/runtime/inline_spec.rb +++ b/spec/bundler/runtime/inline_spec.rb @@ -656,6 +656,20 @@ RSpec.describe "bundler/inline#gemfile" do expect(out).to include("after: [\"Test_Variable\"]") end + it "does not create a lockfile" do + script <<-RUBY + require 'bundler/inline' + + gemfile do + source "https://gem.repo1" + end + + puts Dir.glob("Gemfile.lock") + RUBY + + expect(out).to be_empty + end + it "does not load specified version of psych and stringio", :ruby_repo do build_repo4 do build_gem "psych", "999" @@ -678,4 +692,25 @@ RSpec.describe "bundler/inline#gemfile" do expect(out).to include("The psych gem was resolved to 999") expect(out).to include("The stringio gem was resolved to 999") end + + it "leaves a lockfile in the same directory as the inline script alone" do + install_gemfile <<~G + source "https://gem.repo1" + gem "foo" + G + + original_lockfile = lockfile + + script <<-RUBY, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } + require "bundler/inline" + + gemfile(true) do + source "https://gem.repo1" + + gem "myrack" + end + RUBY + + expect(lockfile).to eq(original_lockfile) + end end |