From 1e5c8afb151c0121e83657fb6061d0e3805d30f6 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Mon, 11 Dec 2023 17:16:37 -0800 Subject: [PATCH] [rubygems/rubygems] Ensure that the lockfile mtime is not altered on frozen install https://github.com/rubygems/rubygems/commit/6847709ee0 --- lib/bundler/definition.rb | 3 ++- spec/bundler/install/deploy_spec.rb | 12 +++++++++--- spec/bundler/install/gemfile/lockfile_spec.rb | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 1de9a72932..5dc711ffde 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -343,7 +343,8 @@ module 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) - SharedHelpers.filesystem_access(file) {|p| FileUtils.touch(p) } + return if Bundler.frozen_bundle? + SharedHelpers.filesystem_access(file) { FileUtils.touch(file) } return end diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 0ddee39ce3..8002978368 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -237,7 +237,9 @@ RSpec.describe "install in deployment or frozen mode" do it "installs gems by default to vendor/bundle" do 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") end @@ -256,11 +258,15 @@ RSpec.describe "install in deployment or frozen mode" do it "works with the `frozen` setting" do bundle "config set frozen true" - bundle "install" + expect do + bundle "install" + end.not_to change { bundled_app_lock.mtime } end 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 it "explodes with the `deployment` setting if you make a change and don't check in the lockfile" do diff --git a/spec/bundler/install/gemfile/lockfile_spec.rb b/spec/bundler/install/gemfile/lockfile_spec.rb index 313e99d0b8..4601d3e2a8 100644 --- a/spec/bundler/install/gemfile/lockfile_spec.rb +++ b/spec/bundler/install/gemfile/lockfile_spec.rb @@ -11,6 +11,11 @@ RSpec.describe "bundle install with a lockfile present" do install_gemfile(gf) 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 let(:gf) { super() + "\n\n File.open('evals', 'a') {|f| f << %(1\n) } unless ENV['BUNDLER_SPEC_NO_APPEND']" }