diff options
author | Andre Arko <andre@arko.net> | 2015-04-13 21:23:01 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-04-13 22:50:16 -0700 |
commit | e41edd133a737ed95581a4e850076c7160289269 (patch) | |
tree | 896f72d91172eea039efd8052dc1362ee5a05402 /lib | |
parent | 3c3d5c635c23abd43c1e2f1b72d55f6d38956119 (diff) | |
download | bundler-e41edd133a737ed95581a4e850076c7160289269.tar.gz |
Merge tag 'v1.9.4'
Version 1.9.4
Conflicts:
lib/bundler/installer.rb
lib/bundler/match_platform.rb
lib/bundler/source/rubygems.rb
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli/gem.rb | 11 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 9 | ||||
-rw-r--r-- | lib/bundler/friendly_errors.rb | 2 | ||||
-rw-r--r-- | lib/bundler/gem_helper.rb | 9 | ||||
-rw-r--r-- | lib/bundler/index.rb | 4 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 31 | ||||
-rw-r--r-- | lib/bundler/lazy_specification.rb | 2 | ||||
-rw-r--r-- | lib/bundler/match_platform.rb | 3 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 7 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 14 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 3 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 19 | ||||
-rw-r--r-- | lib/bundler/source.rb | 5 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 14 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/newgem.gemspec.tt | 12 | ||||
-rw-r--r-- | lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb | 2 | ||||
-rw-r--r-- | lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb | 2 | ||||
-rw-r--r-- | lib/bundler/version.rb | 2 |
18 files changed, 87 insertions, 64 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index a201c89910..f102dd50f9 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -54,6 +54,11 @@ module Bundler "bin/setup.tt" => "bin/setup" } + executables = %w[ + bin/console + bin/setup + ] + if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?", "Codes of conduct can increase contributions to your project by contributors who " \ "prefer collaborative, safe spaces. You can read more about the code of conduct at " \ @@ -108,6 +113,12 @@ module Bundler thor.template("newgem/#{src}", target.join(dst), config) end + executables.each do |file| + path = target.join(file) + executable = (path.stat.mode | 0111) + path.chmod(executable) + end + Bundler.ui.info "Initializing git repo in #{target}" Dir.chdir(target) { `git init`; `git add .` } diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 66d382168d..9643144427 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -284,7 +284,7 @@ module Bundler each do |spec| next if spec.name == 'bundler' out << spec.to_lock - end + end out << "\n" end @@ -577,8 +577,11 @@ module Bundler resolve end - def in_locked_deps?(dep, d) - d && dep.source == d.source + def in_locked_deps?(dep, locked_dep) + # Because the lockfile can't link a dep to a specific remote, we need to + # treat sources as equivalent anytime the locked dep has all the remotes + # that the Gemfile dep does. + locked_dep && locked_dep.source && dep.source && locked_dep.source.include?(dep.source) end def satisfies_locked_spec?(dep) diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index 4bd3e53381..2f24fc179e 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -73,7 +73,7 @@ module Bundler def self.issues_url(exception) 'https://github.com/bundler/bundler/search?q=' \ - "#{CGI.escape(exception.message)}&type=Issues" + "#{CGI.escape(exception.message.lines.first.chomp)}&type=Issues" end end diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 6db31901e4..9aac3e0d75 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -44,6 +44,11 @@ module Bundler install_gem(built_gem_path) end + desc "Build and install #{name}-#{version}.gem into system gems without network access." + task 'install:local' => 'build' do + install_gem(built_gem_path, :local) + end + desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems\n" \ "To prevent publishing in Rubygems use `gem_push=no rake release`" task 'release' => ['build', 'release:guard_clean', @@ -76,9 +81,9 @@ module Bundler File.join(base, 'pkg', file_name) end - def install_gem(built_gem_path=nil) + def install_gem(built_gem_path = nil, local = false) built_gem_path ||= build_gem - out, _ = sh_with_code("gem install '#{built_gem_path}' --local") + out, _ = sh_with_code("gem install '#{built_gem_path}'#{' --local' if local}") raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/] Bundler.ui.confirm "#{name} (#{version}) installed." end diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb index 8076c685e5..ea1edaca21 100644 --- a/lib/bundler/index.rb +++ b/lib/bundler/index.rb @@ -81,10 +81,6 @@ module Bundler end end - def source_types - sources.map{|s| s.class }.uniq - end - alias [] search def <<(spec) diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 6cbdf3a6a9..7365b8f27e 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -98,20 +98,27 @@ module Bundler 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, force) - if install_message.include? 'Installing' - Bundler.ui.confirm install_message - else - Bundler.ui.info install_message + settings = Bundler.settings["build.#{spec.name}"] + messages = nil + + if settings + # Build arguments are global, so this is mutexed + Bundler.rubygems.with_build_args [settings] do + messages = spec.source.install(spec, force) end - Bundler.ui.debug debug_message if debug_message - Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}" + else + messages = spec.source.install(spec, force) + end + + install_message, post_install_message, debug_message = *messages + + if install_message.include? 'Installing' + Bundler.ui.confirm install_message + else + Bundler.ui.info install_message end + Bundler.ui.debug debug_message if debug_message + Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}" if Bundler.settings[:bin] && standalone generate_standalone_bundler_executable_stubs(spec) diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 16f46b8580..1119bdeed8 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -41,7 +41,7 @@ module Bundler out = " #{name} (#{version}-#{platform})\n" end - dependencies.sort_by {|d| d.to_s }.each do |dep| + dependencies.sort_by {|d| d.to_s }.uniq.each do |dep| next if dep.type == :development out << " #{dep.to_lock}\n" end diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb index 757f2c6af4..e6a33ecbad 100644 --- a/lib/bundler/match_platform.rb +++ b/lib/bundler/match_platform.rb @@ -7,8 +7,7 @@ module Bundler def match_platform(p) Gem::Platform::RUBY == platform or platform.nil? or p == platform or - generic(Gem::Platform.new(platform)) == p or - platform === p + generic(Gem::Platform.new(platform)) === p end end end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index df2c515cc5..5ec46acc82 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -323,12 +323,7 @@ module Bundler message << "Source does not contain any versions of '#{requirement}'" end else - message = "Could not find gem '#{requirement}' " - if @index.source_types.include?(Bundler::Source::Rubygems) - message << "in any of the gem sources listed in your Gemfile." - else - message << "in the gems available on this machine." - end + message = "Could not find gem '#{requirement}' in any of the gem sources listed in your Gemfile or installed on this machine." end raise GemNotFound, message end diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 1cb9e72808..3c6c658299 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -161,12 +161,14 @@ module Bundler end def with_build_args(args) - old_args = self.build_args - begin - self.build_args = args - yield - ensure - self.build_args = old_args + ext_lock.synchronize do + old_args = self.build_args + begin + self.build_args = args + yield + ensure + self.build_args = old_args + end end end diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index f83cb30742..be61c2b15b 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -88,9 +88,6 @@ module Bundler raise if $1 != namespaced_file end end - rescue => e - Bundler.ui.debug e - Bundler.ui.warn "Unable to require #{required_file}. #{e.class}: #{e.message}." end end end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 0087f0786a..cd4ad71737 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -35,32 +35,27 @@ module Bundler end def default_bundle_dir - global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle") bundle_dir = find_directory(".bundle") + return nil unless bundle_dir - if bundle_dir && bundle_dir != global_bundle_dir - Pathname.new(bundle_dir) - else - nil - end + global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle") + return nil if bundle_dir == global_bundle_dir + + Pathname.new(bundle_dir) end def in_bundle? find_gemfile end - def chdir_monitor - Bundler.rubygems.ext_lock - end - def chdir(dir, &blk) - chdir_monitor.synchronize do + Bundler.rubygems.ext_lock.synchronize do Dir.chdir dir, &blk end end def pwd - chdir_monitor.synchronize do + Bundler.rubygems.ext_lock.synchronize do Dir.pwd end end diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 213e98fb98..869931a1f0 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -27,5 +27,10 @@ module Bundler def can_lock?(spec) spec.source == self end + + def include?(other) + other == self + end + end end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index a269a22133..66a0b72a06 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -38,11 +38,15 @@ module Bundler end def eql?(o) - o.is_a?(Rubygems) && remotes_equal?(o.remotes) + o.is_a?(Rubygems) && o.credless_remotes == credless_remotes end alias == eql? + def include?(o) + o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty? + end + def can_lock?(spec) spec.source.is_a?(Rubygems) end @@ -203,6 +207,10 @@ module Bundler protected + def credless_remotes + remotes.map(&method(:suppress_configured_credentials)) + end + def remotes_for_spec(spec) specs.search_all(spec.name).inject([]) do |uris, s| uris << s.remote if s.remote @@ -387,10 +395,6 @@ module Bundler spec.loaded_from && spec.loaded_from.include?("specifications/default/") end - def remotes_equal?(other_remotes) - remotes.map(&method(:suppress_configured_credentials)) == other_remotes.map(&method(:suppress_configured_credentials)) - end - end end end diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt index 4749a9a70e..e630801026 100644 --- a/lib/bundler/templates/newgem/newgem.gemspec.tt +++ b/lib/bundler/templates/newgem/newgem.gemspec.tt @@ -16,6 +16,14 @@ Gem::Specification.new do |spec| spec.license = "MIT" <%- end -%> + # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or + # delete this section to allow pushing this gem to any host. + if spec.respond_to?(:metadata) + spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" + else + raise "RubyGems 2.0 or newer is required to protect against public gem pushes." + end + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } @@ -24,10 +32,6 @@ Gem::Specification.new do |spec| spec.extensions = ["ext/<%=config[:underscored_name]%>/extconf.rb"] <%- end -%> - if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server." - end - spec.add_development_dependency "bundler", "~> <%= config[:bundler_version] %>" spec.add_development_dependency "rake", "~> 10.0" <%- if config[:ext] -%> diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb index 4ee5708a56..7cde9fa5eb 100644 --- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb @@ -61,7 +61,7 @@ module Bundler::Molinillo hash[name] = vertex.dup.tap { |v| v.graph = self } end end - @root_vertices = Hash[vertices.select { |n, _v| other.root_vertices[n] }] + @root_vertices = Hash[@vertices.select { |n, _v| other.root_vertices[n] }] @edges = other.edges.map do |edge| Edge.new( vertex_named(edge.origin.name), diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb b/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb index 0736b89c3c..2cf1b60b12 100644 --- a/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +++ b/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb @@ -1,3 +1,3 @@ module Bundler::Molinillo - VERSION = '0.2.1' + VERSION = '0.2.3' end diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 1854799dcb..3dfc25db76 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -2,5 +2,5 @@ module Bundler # We're doing this because we might write tests that deal # with other versions of bundler and we are unsure how to # handle this better. - VERSION = "1.9.1" unless defined?(::Bundler::VERSION) + VERSION = "1.9.4" unless defined?(::Bundler::VERSION) end |