aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-03-19 10:36:13 +0100
committerlolwut <lol@wut.com>2012-03-19 19:02:30 +0100
commitd376a1a7d738f57fd3bd6091f1b72e6e7aca3727 (patch)
treef5ea9a0c9aeeb6fb7344d7cd2bc58929c35da68d
parent7ea338f06332cb397e3d4ead548463e39c863932 (diff)
downloadbundler-d376a1a7d738f57fd3bd6091f1b72e6e7aca3727.tar.gz
Do not resolve if the local override did not change.
-rw-r--r--lib/bundler/definition.rb60
-rw-r--r--lib/bundler/source.rb8
2 files changed, 44 insertions, 24 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 892ff5ea..c5193f31 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -74,15 +74,7 @@ module Bundler
@source_changes = converge_sources
@dependency_changes = converge_dependencies
-
- @local_changes = Bundler.settings.local_overrides.map do |k,v|
- spec = @dependencies.find { |s| s.name == k }
- source = spec && spec.source
- if source && source.respond_to?(:local_override!)
- source.local_override!(v)
- true
- end
- end.any?
+ @local_changes = converge_locals
fixup_dependency_types!
end
@@ -356,23 +348,49 @@ module Bundler
msg
end
- def converge_paths
- @sources.any? do |source|
- next unless source.instance_of?(Source::Path)
+ # Check if the specs of the given source changed
+ # according to the locked source. A block should be
+ # in order to specify how the locked version of
+ # the source should be found.
+ def specs_changed?(source, &block)
+ locked = @locked_sources.find(&block)
- locked = @locked_sources.find do |ls|
- ls.class == source.class && ls.path == source.path
+ if locked
+ unlocking = locked.specs.any? do |spec|
+ @locked_specs.any? do |locked_spec|
+ locked_spec.source != locked
+ end
end
+ end
- if locked
- unlocking = locked.specs.any? do |spec|
- @locked_specs.any? do |locked_spec|
- locked_spec.source != locked
- end
- end
+ !locked || unlocking || source.specs != locked.specs
+ end
+
+ # Get all locals and override their matching sources.
+ # Return true if any of the locals changed (for example,
+ # they point to a new revision) or depend on new specs.
+ def converge_locals
+ locals = []
+
+ Bundler.settings.local_overrides.map do |k,v|
+ spec = @dependencies.find { |s| s.name == k }
+ source = spec && spec.source
+ if source && source.respond_to?(:local_override!)
+ locals << [ source, source.local_override!(v) ]
end
+ end
- !locked || unlocking || source.specs != locked.specs
+ locals.any? do |source, changed|
+ changed || specs_changed?(source) { |o| source.class === o.class && source.uri == o.uri }
+ end
+ end
+
+ def converge_paths
+ @sources.any? do |source|
+ next unless source.instance_of?(Source::Path)
+ specs_changed?(source) do |ls|
+ ls.class == source.class && ls.path == source.path
+ end
end
end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 23676dec..195c7dc5 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -714,13 +714,15 @@ module Bundler
"#{git_proxy.branch} but Gemfile specifies #{options["branch"]}"
end
- rev = cached_revision
+ changed = cached_revision && cached_revision != git_proxy.revision
- if rev && rev != git_proxy.revision && !git_proxy.contains?(rev)
- raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(rev)} " \
+ if changed && !git_proxy.contains?(cached_revision)
+ raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
"but the current branch in your local override for #{name} does not contain such commit. " \
"Please make sure your branch is up to date."
end
+
+ changed
end
# TODO: actually cache git specs