lib/bundler/source/git.rb in bundler-1.15.4 vs lib/bundler/source/git.rb in bundler-1.16.0.pre.1

- old
+ new

@@ -1,7 +1,8 @@ # frozen_string_literal: true -require "fileutils" + +require "bundler/vendored_fileutils" require "uri" require "digest/sha1" module Bundler class Source @@ -16,11 +17,11 @@ @allow_cached = false @allow_remote = false # Stringify options that could be set as symbols - %w(ref branch tag revision).each {|k| options[k] = options[k].to_s if options[k] } + %w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] } @uri = options["uri"] || "" @branch = options["branch"] @ref = options["ref"] || options["branch"] || options["tag"] || "master" @submodules = options["submodules"] @@ -37,11 +38,11 @@ def to_lock out = String.new("GIT\n") out << " remote: #{@uri}\n" out << " revision: #{revision}\n" - %w(ref branch tag submodules).each do |opt| + %w[ref branch tag submodules].each do |opt| out << " #{opt}: #{options[opt]}\n" if options[opt] end out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB out << " specs:\n" end @@ -167,30 +168,28 @@ end def install(spec, options = {}) force = options[:force] - Bundler.ui.info "Using #{version_message(spec)} from #{self}" + print_using_message "Using #{version_message(spec)} from #{self}" - if requires_checkout? && !@copied && !force + if (requires_checkout? && !@copied) || force Bundler.ui.debug " * Checking out revision: #{ref}" git_proxy.copy_to(install_path, submodules) serialize_gemspecs_in(install_path) @copied = true - elsif force - git_proxy.copy_to(install_path, submodules) end generate_bin_options = { :disable_extensions => !Bundler.rubygems.spec_missing_extensions?(spec), :build_args => options[:build_args] } generate_bin(spec, generate_bin_options) requires_checkout? ? spec.post_install_message : nil end def cache(spec, custom_path = nil) app_cache_path = app_cache_path(custom_path) - return unless Bundler.settings[:cache_all] + return unless Bundler.feature_flag.cache_all? return if path == app_cache_path cached! FileUtils.rm_rf(app_cache_path) git_proxy.checkout if requires_checkout? git_proxy.copy_to(app_cache_path, @submodules) @@ -208,17 +207,15 @@ # of the git repository. When using the same git repository # across different projects, this cache will be shared. # When using local git repos, this is set to the local repo. def cache_path @cache_path ||= begin - git_scope = "#{base_name}-#{uri_hash}" - - if Bundler.requires_sudo? - Bundler.user_bundle_path.join("cache/git", git_scope) + if Bundler.requires_sudo? || Bundler.feature_flag.global_gem_cache? + Bundler.user_cache else - Bundler.cache.join("git", git_scope) - end + Bundler.bundle_path.join("cache", "bundler") + end.join("git", git_scope) end end def app_cache_dirname "#{base_name}-#{shortref_for_path(cached_revision || revision)}" @@ -302,13 +299,13 @@ @git_proxy ||= GitProxy.new(cache_path, uri, ref, cached_revision, self) end def fetch git_proxy.checkout - rescue GitError + rescue GitError => e raise unless Bundler.feature_flag.allow_offline_install? - Bundler.ui.warn "Using cached git data because of network errors" + Bundler.ui.warn "Using cached git data because of network errors:\n#{e}" end # no-op, since we validate when re-serializing the gemspec def validate_spec(_spec); end @@ -316,9 +313,17 @@ def load_gemspec(file) stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent) stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.untaint StubSpecification.from_stub(stub) end + end + + def git_scope + "#{base_name}-#{uri_hash}" + end + + def extension_cache_slug(_) + extension_dir_name end end end end