[rubygems/rubygems] Fix bundle lock --add-checksums
when gems are already installed
https://github.com/rubygems/rubygems/commit/a087c452ad
This commit is contained in:
parent
a6fd6cb72f
commit
29d3ea1e84
@ -186,13 +186,13 @@ module Bundler
|
||||
def setup_domain!(options = {})
|
||||
prefer_local! if options[:"prefer-local"]
|
||||
|
||||
if options[:local] || no_install_needed?
|
||||
Bundler.settings.set_command_option(:jobs, 1) if no_install_needed? # to avoid the overhead of Bundler::Worker
|
||||
with_cache!
|
||||
false
|
||||
else
|
||||
if options[:add_checksums] || (!options[:local] && install_needed?)
|
||||
remotely!
|
||||
true
|
||||
else
|
||||
Bundler.settings.set_command_option(:jobs, 1) unless install_needed? # to avoid the overhead of Bundler::Worker
|
||||
with_cache!
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@ -513,26 +513,11 @@ module Bundler
|
||||
end
|
||||
|
||||
def nothing_changed?
|
||||
return false unless lockfile_exists?
|
||||
|
||||
!@source_changes &&
|
||||
!@dependency_changes &&
|
||||
!@current_platform_missing &&
|
||||
@new_platforms.empty? &&
|
||||
!@path_changes &&
|
||||
!@local_changes &&
|
||||
!@missing_lockfile_dep &&
|
||||
!@unlocking_bundler &&
|
||||
!@locked_spec_with_missing_deps &&
|
||||
!@locked_spec_with_invalid_deps
|
||||
end
|
||||
|
||||
def no_install_needed?
|
||||
no_resolve_needed? && !missing_specs?
|
||||
!something_changed?
|
||||
end
|
||||
|
||||
def no_resolve_needed?
|
||||
!unlocking? && nothing_changed?
|
||||
!resolve_needed?
|
||||
end
|
||||
|
||||
def unlocking?
|
||||
@ -544,13 +529,36 @@ module Bundler
|
||||
def add_checksums
|
||||
@locked_checksums = true
|
||||
|
||||
setup_domain!
|
||||
setup_domain!(add_checksums: true)
|
||||
|
||||
specs # force materialization to real specifications, so that checksums are fetched
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def install_needed?
|
||||
resolve_needed? || missing_specs?
|
||||
end
|
||||
|
||||
def something_changed?
|
||||
return true unless lockfile_exists?
|
||||
|
||||
@source_changes ||
|
||||
@dependency_changes ||
|
||||
@current_platform_missing ||
|
||||
@new_platforms.any? ||
|
||||
@path_changes ||
|
||||
@local_changes ||
|
||||
@missing_lockfile_dep ||
|
||||
@unlocking_bundler ||
|
||||
@locked_spec_with_missing_deps ||
|
||||
@locked_spec_with_invalid_deps
|
||||
end
|
||||
|
||||
def resolve_needed?
|
||||
unlocking? || something_changed?
|
||||
end
|
||||
|
||||
def should_add_extra_platforms?
|
||||
!lockfile_exists? && generic_local_platform_is_ruby? && !Bundler.settings[:force_ruby_platform]
|
||||
end
|
||||
|
@ -1894,6 +1894,68 @@ RSpec.describe "bundle lock" do
|
||||
L
|
||||
end
|
||||
|
||||
it "adds checksums to an existing lockfile, when gems are already installed" do
|
||||
build_repo4 do
|
||||
build_gem "nokogiri", "1.14.2"
|
||||
build_gem "nokogiri", "1.14.2" do |s|
|
||||
s.platform = "x86_64-linux"
|
||||
end
|
||||
end
|
||||
|
||||
gemfile <<-G
|
||||
source "https://gem.repo4"
|
||||
|
||||
gem "nokogiri"
|
||||
G
|
||||
|
||||
lockfile <<~L
|
||||
GEM
|
||||
remote: https://gem.repo4/
|
||||
specs:
|
||||
nokogiri (1.14.2)
|
||||
nokogiri (1.14.2-x86_64-linux)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
nokogiri
|
||||
|
||||
BUNDLED WITH
|
||||
#{Bundler::VERSION}
|
||||
L
|
||||
|
||||
simulate_platform "x86_64-linux" do
|
||||
bundle "install"
|
||||
|
||||
bundle "lock --add-checksums"
|
||||
end
|
||||
|
||||
checksums = checksums_section do |c|
|
||||
c.checksum gem_repo4, "nokogiri", "1.14.2"
|
||||
c.checksum gem_repo4, "nokogiri", "1.14.2", "x86_64-linux"
|
||||
end
|
||||
|
||||
expect(lockfile).to eq <<~L
|
||||
GEM
|
||||
remote: https://gem.repo4/
|
||||
specs:
|
||||
nokogiri (1.14.2)
|
||||
nokogiri (1.14.2-x86_64-linux)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
nokogiri
|
||||
#{checksums}
|
||||
BUNDLED WITH
|
||||
#{Bundler::VERSION}
|
||||
L
|
||||
end
|
||||
|
||||
it "generates checksums by default if configured to do so" do
|
||||
build_repo4 do
|
||||
build_gem "nokogiri", "1.14.2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user