Skip to content

Commit

Permalink
fix needing to sync lockfiles when an explicit dep becomes implicit (#15
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ccutrer authored Oct 10, 2023
1 parent 41e3bd9 commit 0572ff9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/multilock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def after_install_all(install: true)
up_to_date = false
Bundler.settings.temporary(frozen: true) do
Bundler.ui.silence do
up_to_date = checker.base_check(lockfile_definition) &&
up_to_date = checker.base_check(lockfile_definition, check_missing_deps: true) &&
checker.check(lockfile_definition)
end
end
Expand Down
7 changes: 5 additions & 2 deletions lib/bundler/multilock/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def run(skip_base_checks: false)

# this is mostly equivalent to the built in checks in `bundle check`, but even
# more conservative, and returns false instead of exiting on failure
def base_check(lockfile_definition, log_missing: false, return_missing: false)
def base_check(lockfile_definition, log_missing: false, return_missing: false, check_missing_deps: false)
return return_missing ? [] : false unless lockfile_definition[:lockfile].file?

Multilock.prepare_block = lockfile_definition[:prepare]
Expand All @@ -83,7 +83,10 @@ def base_check(lockfile_definition, log_missing: false, return_missing: false)

return not_installed if return_missing

not_installed.empty? && definition.no_resolve_needed?
return false unless not_installed.empty? && definition.no_resolve_needed?
return true unless check_missing_deps

(definition.locked_gems.dependencies.values - definition.dependencies).empty?
ensure
Multilock.prepare_block = nil
end
Expand Down
20 changes: 20 additions & 0 deletions spec/bundler/multilock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,26 @@
end
end

it "removes now-missing explicit dependencies from secondary lockfiles" do
with_gemfile(<<~RUBY) do
gem "inst-jobs", "3.1.13"
gem "activerecord-pg-extensions"
lockfile("alt") {}
RUBY
invoke_bundler("install")

write_gemfile(<<~RUBY)
gem "inst-jobs", "3.1.13"
lockfile("alt") {}
RUBY

invoke_bundler("install")
expect(File.read("Gemfile.lock")).to eq File.read("Gemfile.alt.lock")
end
end

private

def create_local_gem(name, content = "", subdirectory: true)
Expand Down

0 comments on commit 0572ff9

Please sign in to comment.