[rubygems/rubygems] Ensure that the lockfile mtime is not altered on frozen install

https://github.com/rubygems/rubygems/commit/6847709ee0
This commit is contained in:
Martin Emde 2023-12-11 17:16:37 -08:00 committed by git
parent 6b3abcf462
commit 1e5c8afb15
3 changed files with 16 additions and 4 deletions

View File

@ -343,7 +343,8 @@ module Bundler
preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler)) preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
SharedHelpers.filesystem_access(file) {|p| FileUtils.touch(p) } return if Bundler.frozen_bundle?
SharedHelpers.filesystem_access(file) { FileUtils.touch(file) }
return return
end end

View File

@ -237,7 +237,9 @@ RSpec.describe "install in deployment or frozen mode" do
it "installs gems by default to vendor/bundle" do it "installs gems by default to vendor/bundle" do
bundle "config set deployment true" bundle "config set deployment true"
bundle "install" expect do
bundle "install"
end.not_to change { bundled_app_lock.mtime }
expect(out).to include("vendor/bundle") expect(out).to include("vendor/bundle")
end end
@ -256,11 +258,15 @@ RSpec.describe "install in deployment or frozen mode" do
it "works with the `frozen` setting" do it "works with the `frozen` setting" do
bundle "config set frozen true" bundle "config set frozen true"
bundle "install" expect do
bundle "install"
end.not_to change { bundled_app_lock.mtime }
end end
it "works with BUNDLE_FROZEN if you didn't change anything" do it "works with BUNDLE_FROZEN if you didn't change anything" do
bundle :install, env: { "BUNDLE_FROZEN" => "true" } expect do
bundle :install, env: { "BUNDLE_FROZEN" => "true" }
end.not_to change { bundled_app_lock.mtime }
end end
it "explodes with the `deployment` setting if you make a change and don't check in the lockfile" do it "explodes with the `deployment` setting if you make a change and don't check in the lockfile" do

View File

@ -11,6 +11,11 @@ RSpec.describe "bundle install with a lockfile present" do
install_gemfile(gf) install_gemfile(gf)
end end
it "touches the lockfile on install even when nothing has changed" do
subject
expect { bundle :install }.to change { bundled_app_lock.mtime }
end
context "gemfile evaluation" do context "gemfile evaluation" do
let(:gf) { super() + "\n\n File.open('evals', 'a') {|f| f << %(1\n) } unless ENV['BUNDLER_SPEC_NO_APPEND']" } let(:gf) { super() + "\n\n File.open('evals', 'a') {|f| f << %(1\n) } unless ENV['BUNDLER_SPEC_NO_APPEND']" }