summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSamuel E. Giddins <segiddins@segiddins.me>2015-03-26 21:02:42 -0700
committerSamuel E. Giddins <segiddins@segiddins.me>2015-03-26 21:02:42 -0700
commit97cb33cd648fe6f1bda3329e77716a6983a70db2 (patch)
tree08f2f8d896ec453626fc795c6d46d93df250ebb3 /lib
parente04dff820ff08fad9feffd3e8ed5312967c48863 (diff)
downloadbundler-97cb33cd648fe6f1bda3329e77716a6983a70db2.tar.gz
[Installer] Add option to force installationseg-force
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb4
-rw-r--r--lib/bundler/installer.rb18
-rw-r--r--lib/bundler/source/git.rb4
-rw-r--r--lib/bundler/source/path.rb2
-rw-r--r--lib/bundler/source/rubygems.rb4
5 files changed, 19 insertions, 13 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index b1a19f5530..077c367f03 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -134,6 +134,8 @@ module Bundler
"Do not attempt to fetch gems remotely and use the gem cache instead"
method_option "no-cache", :type => :boolean, :banner =>
"Don't update the existing gem cache."
+ method_option "force", :type => :boolean, :banner =>
+ "Force downloading every gem."
method_option "no-prune", :type => :boolean, :banner =>
"Don't remove stale gems from the cache."
method_option "path", :type => :string, :banner =>
@@ -175,6 +177,8 @@ module Bundler
"Only output warnings and errors."
method_option "source", :type => :array, :banner =>
"Update a specific source (and all gems associated with it)"
+ method_option "force", :type => :boolean, :banner =>
+ "Force downloading every gem."
def update(*gems)
require 'bundler/cli/update'
Update.new(options, gems).run
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 10526115a4..6cbdf3a6a9 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -79,29 +79,31 @@ module Bundler
options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
end
+ force = options["force"]
+
# the order that the resolver provides is significant, since
# dependencies might actually affect the installation of a gem.
# that said, it's a rare situation (other than rake), and parallel
# installation is just SO MUCH FASTER. so we let people opt in.
jobs = [Bundler.settings[:jobs].to_i-1, 1].max
if jobs > 1 && can_install_in_parallel?
- install_in_parallel jobs, options[:standalone]
+ install_in_parallel jobs, options[:standalone], force
else
- install_sequentially options[:standalone]
+ install_sequentially options[:standalone], force
end
lock unless Bundler.settings[:frozen]
generate_standalone(options[:standalone]) if options[:standalone]
end
- def install_gem_from_spec(spec, standalone = false, worker = 0)
+ def install_gem_from_spec(spec, standalone = false, worker = 0, force = false)
# Fetch the build settings, if there are any
settings = Bundler.settings["build.#{spec.name}"]
install_message = nil
post_install_message = nil
debug_message = nil
Bundler.rubygems.with_build_args [settings] do
- install_message, post_install_message, debug_message = spec.source.install(spec)
+ install_message, post_install_message, debug_message = spec.source.install(spec, force)
if install_message.include? 'Installing'
Bundler.ui.confirm install_message
else
@@ -258,16 +260,16 @@ module Bundler
end
end
- def install_sequentially(standalone)
+ def install_sequentially(standalone, force = false)
specs.each do |spec|
- message = install_gem_from_spec spec, standalone, 0
+ message = install_gem_from_spec spec, standalone, 0, force
if message
Installer.post_install_messages[spec.name] = message
end
end
end
- def install_in_parallel(size, standalone)
+ def install_in_parallel(size, standalone, force = false)
name2spec = {}
remains = {}
enqueued = {}
@@ -278,7 +280,7 @@ module Bundler
worker_pool = Worker.new size, lambda { |name, worker_num|
spec = name2spec[name]
- message = install_gem_from_spec spec, standalone, worker_num
+ message = install_gem_from_spec spec, standalone, worker_num, force
{ :name => spec.name, :post_install => message }
}
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index 62d615088c..230aa8fc40 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -159,9 +159,9 @@ module Bundler
local_specs
end
- def install(spec)
+ def install(spec, force = false)
debug = nil
- if requires_checkout? && !@copied
+ if requires_checkout? && !@copied && !force
debug = " * Checking out revision: #{ref}"
git_proxy.copy_to(install_path, submodules)
serialize_gemspecs_in(install_path)
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 2b53bc7831..862fbcb97a 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -69,7 +69,7 @@ module Bundler
File.basename(expanded_path.to_s)
end
- def install(spec)
+ def install(spec, force = false)
generate_bin(spec, :disable_extensions)
["Using #{version_message(spec)} from #{to_s}", nil]
end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 8f504bcf7f..6d53c7853b 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -81,8 +81,8 @@ module Bundler
end
end
- def install(spec)
- return ["Using #{version_message(spec)}", nil] if installed_specs[spec].any?
+ def install(spec, force = false)
+ return ["Using #{version_message(spec)}", nil] if installed_specs[spec].any? && !force
# Download the gem to get the spec, because some specs that are returned
# by rubygems.org are broken and wrong.