Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
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
1 change: 1 addition & 0 deletions lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def self.settings_method(name, key, &default)
settings_flag(:allow_bundler_dependency_conflicts) { bundler_2_mode? }
settings_flag(:allow_offline_install) { bundler_2_mode? }
settings_flag(:auto_clean_without_path) { bundler_2_mode? }
settings_flag(:auto_config_jobs) { bundler_2_mode? }
settings_flag(:cache_all) { bundler_2_mode? }
settings_flag(:cache_command_is_package) { bundler_2_mode? }
settings_flag(:console_command) { !bundler_2_mode? }
Expand Down
32 changes: 27 additions & 5 deletions lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,36 @@ def generate_standalone_bundler_executable_stubs(spec)
# installation is SO MUCH FASTER. so we let people opt in.
def install(options)
force = options["force"]
jobs = options.delete(:jobs) do
if can_install_in_parallel?
[Bundler.settings[:jobs].to_i - 1, 1].max
jobs = installation_parallelization(options)
install_in_parallel jobs, options[:standalone], force
end

def installation_parallelization(options)
if jobs = options.delete(:jobs)
return jobs
end

return 1 unless can_install_in_parallel?

auto_config_jobs = Bundler.feature_flag.auto_config_jobs?
if jobs = Bundler.settings[:jobs]
if auto_config_jobs
jobs
else
1
[jobs.pred, 1].max
end
elsif auto_config_jobs
processor_count
else
1
end
install_in_parallel jobs, options[:standalone], force
end

def processor_count
require "etc"
Etc.nprocessors
rescue
1
end

def load_plugins
Expand Down
3 changes: 3 additions & 0 deletions lib/bundler/installer/parallel_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def initialize(installer, all_specs, size, standalone, force)
@force = force
@specs = all_specs.map {|s| SpecInstallation.new(s) }
@spec_set = all_specs
@rake = @specs.find {|s| s.name == "rake" }
end

def call
Expand Down Expand Up @@ -218,6 +219,8 @@ def require_tree_for_spec(spec)
# are installed.
def enqueue_specs
@specs.select(&:ready_to_enqueue?).each do |spec|
next if @rake && !@rake.installed? && spec.name != @rake.name

if spec.dependencies_installed? @specs
spec.state = :enqueued
worker_pool.enq spec
Expand Down
2 changes: 2 additions & 0 deletions lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Settings
allow_offline_install
auto_clean_without_path
auto_install
auto_config_jobs
cache_all
cache_all_platforms
cache_command_is_package
Expand Down Expand Up @@ -58,6 +59,7 @@ class Settings
].freeze

NUMBER_KEYS = %w[
jobs
redirect
retry
ssl_verify_mode
Expand Down
15 changes: 10 additions & 5 deletions spec/quality_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,21 @@ def check_for_specific_pronouns(filename)

it "documents all used settings" do
exemptions = %w[
auto_config_jobs
cache_command_is_package
console_command
default_cli_command
deployment_means_frozen
forget_cli_options
gem.coc
gem.mit
inline
lockfile_uses_separate_rubygems_sources
use_gem_version_promoter_for_major_updates
warned_version
viz_command
]

all_settings = Hash.new {|h, k| h[k] = [] }
documented_settings = exemptions
documented_settings = []

Bundler::Settings::BOOL_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::BOOL_KEYS" }
Bundler::Settings::NUMBER_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::NUMBER_KEYS" }
Expand All @@ -200,8 +199,14 @@ def check_for_specific_pronouns(filename)
documented_settings = File.read("man/bundle-config.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten
end

documented_settings.each {|s| all_settings.delete(s) }
exemptions.each {|s| all_settings.delete(s) }
documented_settings.each do |s|
all_settings.delete(s)
expect(exemptions.delete(s)).to be_nil, "setting #{s} was exempted but was actually documented"
end

exemptions.each do |s|
expect(all_settings.delete(s)).to be_truthy, "setting #{s} was exempted but unused"
end
error_messages = all_settings.map do |setting, refs|
"The `#{setting}` setting is undocumented\n\t- #{refs.join("\n\t- ")}\n"
end
Expand Down