Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix needing to sync lockfiles when an explicit dep becomes implicit #15

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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