lib/bundler/definition.rb in bundler-1.0.22 vs lib/bundler/definition.rb in bundler-1.1.pre
- old
+ new
@@ -59,38 +59,21 @@
end
@unlock[:gems] ||= []
@unlock[:sources] ||= []
- current_platform = Bundler.rubygems.platforms.map { |p| generic(p) }.compact.last
+ current_platform = Gem.platforms.map { |p| generic(p) }.compact.last
@new_platform = !@platforms.include?(current_platform)
@platforms |= [current_platform]
eager_unlock = expand_dependencies(@unlock[:gems])
@unlock[:gems] = @locked_specs.for(eager_unlock).map { |s| s.name }
converge_sources
converge_dependencies
-
- fixup_dependency_types!
end
- def fixup_dependency_types!
- # XXX This is a temporary workaround for a bug when using rubygems 1.8.15
- # where Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
- # doesn't carry a notion of the dependency type, if you use
- # add_development_dependency in a gemspec that's loaded with the gemspec
- # directive, the lockfile dependencies and resolved dependencies end up
- # with a mismatch on #type.
- # Test coverage to catch a regression on this is in gemspec_spec.rb
- @dependencies.each do |d|
- if ld = @locked_deps.find { |l| l.name == d.name }
- ld.instance_variable_set(:@type, d.type)
- end
- end
- end
-
def resolve_with_cache!
raise "Specs already loaded" if @specs
@sources.each { |s| s.cached! }
specs
end
@@ -171,11 +154,11 @@
end
def index
@index ||= Index.build do |idx|
@sources.each do |s|
- idx.use s.specs
+ idx.use s.specs(@dependencies)
end
end
end
def rubygems_index
@@ -195,21 +178,21 @@
end
def lock(file)
contents = to_lock
- # Convert to \r\n if the existing lock has them
- # i.e., Windows with `git config core.autocrlf=true`
- contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
-
return if @lockfile_contents == contents
if Bundler.settings[:frozen]
# TODO: Warn here if we got here.
return
end
+ # Convert to \r\n if the existing lock has them
+ # i.e., Windows with `git config core.autocrlf=true`
+ contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
+
File.open(file, 'wb'){|f| f.puts(contents) }
end
def to_lock
out = ""
@@ -240,32 +223,26 @@
out << "\n"
out << "DEPENDENCIES\n"
handled = []
dependencies.
- sort_by { |d| d.to_s }.
+ sort_by { |d| d.name }.
each do |dep|
next if handled.include?(dep.name)
out << dep.to_lock
handled << dep.name
end
out
end
- def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
+ def ensure_equivalent_gemfile_and_lockfile
changes = false
- msg = "You are trying to install in deployment mode after changing\n" \
- "your Gemfile. Run `bundle install` elsewhere and add the\n" \
- "updated Gemfile.lock to version control."
+ msg = "You have modified your Gemfile in development but did not check\n" \
+ "the resulting snapshot (Gemfile.lock) into version control"
- unless explicit_flag
- msg += "\n\nIf this is a development machine, remove the Gemfile " \
- "freeze \nby running `bundle install --no-deployment`."
- end
-
added = []
deleted = []
changed = []
if @locked_sources != @sources
@@ -308,11 +285,10 @@
end
msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
- msg << "\n"
raise ProductionError, msg if added.any? || deleted.any? || changed.any?
end
private
@@ -389,13 +365,11 @@
other = s.source.specs[s].first
# If the spec is no longer in the path source, unlock it. This
# commonly happens if the version changed in the gemspec
next unless other
-
- deps2 = other.dependencies.select { |d| d.type != :development }
# If the dependencies of the path source have changed, unlock it
- next unless s.dependencies.sort == deps2.sort
+ next unless s.dependencies.sort == other.dependencies.sort
end
converged << s
end