diff --git a/lib/bundler/multilock.rb b/lib/bundler/multilock.rb index 0ca4956..d8782a7 100644 --- a/lib/bundler/multilock.rb +++ b/lib/bundler/multilock.rb @@ -5,6 +5,7 @@ require_relative "multilock/ext/dsl" require_relative "multilock/ext/plugin" require_relative "multilock/ext/plugin/dsl" +require_relative "multilock/ext/shared_helpers" require_relative "multilock/ext/source" require_relative "multilock/ext/source_list" require_relative "multilock/version" @@ -427,7 +428,7 @@ def write_lockfile(lockfile_definition, lockfile, install:, dependency_changes: end resolved_remotely = false - begin + accesses = begin previous_ui_level = Bundler.ui.level Bundler.ui.level = "warn" begin @@ -438,7 +439,9 @@ def write_lockfile(lockfile_definition, lockfile, install:, dependency_changes: definition.resolve_remotely! resolved_remotely = true end - definition.lock(lockfile_definition[:lockfile], true) + SharedHelpers.capture_filesystem_access do + definition.lock(lockfile_definition[:lockfile], true) + end ensure Bundler.ui.level = previous_ui_level end @@ -451,7 +454,7 @@ def write_lockfile(lockfile_definition, lockfile, install:, dependency_changes: end end - !definition.nothing_changed? + accesses && !accesses.empty? end end diff --git a/lib/bundler/multilock/ext/shared_helpers.rb b/lib/bundler/multilock/ext/shared_helpers.rb new file mode 100644 index 0000000..8ab4106 --- /dev/null +++ b/lib/bundler/multilock/ext/shared_helpers.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Bundler + module Multilock + module Ext + module SharedHeleprs + module ClassMethods + ::Bundler::SharedHelpers.singleton_class.prepend(self) + ::Bundler::SharedHelpers.instance_variable_set(:@filesystem_accesses, nil) + + def capture_filesystem_access + @filesystem_accesses = [] + yield + @filesystem_accesses + ensure + @filesystem_accesses = nil + end + + def filesystem_access(path, action = :write) + @filesystem_accesses << [path, action] if @filesystem_accesses + + super + end + end + end + end + end +end