Commit 1711e76c authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4825 from CocoaPods/seg-specs-state-root-name

[SpecsState] Ensure only root names are stored
parents 55b24295 24d29068
...@@ -45,6 +45,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -45,6 +45,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#4823](https://github.com/CocoaPods/CocoaPods/issues/4823) [#4823](https://github.com/CocoaPods/CocoaPods/issues/4823)
* Determine whether an external source needs to be fetched when updating a
dependency regardless of subspec names.
[Samuel Giddins](https://github.com/segiddins)
[#4821](https://github.com/CocoaPods/CocoaPods/issues/4821)
## 1.0.0.beta.2 (2016-01-05) ## 1.0.0.beta.2 (2016-01-05)
......
...@@ -202,7 +202,7 @@ module Pod ...@@ -202,7 +202,7 @@ module Pod
pods_state pods_state
else else
state = SpecsState.new state = SpecsState.new
state.added.concat(podfile.dependencies.map(&:name).uniq) state.added.merge(podfile.dependencies.map(&:root_name))
state state
end end
end end
...@@ -477,8 +477,8 @@ module Pod ...@@ -477,8 +477,8 @@ module Pod
if update_mode == :all if update_mode == :all
deps_to_fetch = deps_with_external_source deps_to_fetch = deps_with_external_source
else else
deps_to_fetch = deps_with_external_source.select { |dep| pods_to_fetch.include?(dep.name) } deps_to_fetch = deps_with_external_source.select { |dep| pods_to_fetch.include?(dep.root_name) }
deps_to_fetch_if_needed = deps_with_external_source.select { |dep| result.podfile_state.unchanged.include?(dep.name) } deps_to_fetch_if_needed = deps_with_external_source.select { |dep| result.podfile_state.unchanged.include?(dep.root_name) }
deps_to_fetch += deps_to_fetch_if_needed.select do |dep| deps_to_fetch += deps_to_fetch_if_needed.select do |dep|
sandbox.specification(dep.root_name).nil? || sandbox.specification(dep.root_name).nil? ||
!dep.external_source[:path].nil? || !dep.external_source[:path].nil? ||
......
...@@ -78,7 +78,7 @@ module Pod ...@@ -78,7 +78,7 @@ module Pod
state.add_name(name, pod_state(name)) state.add_name(name, pod_state(name))
end end
else else
state.added.concat(resolved_pods) state.added.merge(resolved_pods)
end end
state state
end end
......
require 'set'
module Pod module Pod
class Installer class Installer
class Analyzer class Analyzer
...@@ -17,32 +19,38 @@ module Pod ...@@ -17,32 +19,38 @@ module Pod
# (`:added`, `:removed`, `:changed` or `:unchanged`). # (`:added`, `:removed`, `:changed` or `:unchanged`).
# #
def initialize(pods_by_state = nil) def initialize(pods_by_state = nil)
@added = [] @added = Set.new
@deleted = [] @deleted = Set.new
@changed = [] @changed = Set.new
@unchanged = [] @unchanged = Set.new
if pods_by_state if pods_by_state
@added = pods_by_state[:added] || [] {
@deleted = pods_by_state[:removed] || [] :added => :added,
@changed = pods_by_state[:changed] || [] :changed => :changed,
@unchanged = pods_by_state[:unchanged] || [] :removed => :deleted,
:unchanged => :unchanged,
}.each do |state, spec_state|
Array(pods_by_state[state]).each do |name|
add_name(name, spec_state)
end
end
end end
end end
# @return [Array<String>] the names of the pods that were added. # @return [Set<String>] the names of the pods that were added.
# #
attr_accessor :added attr_accessor :added
# @return [Array<String>] the names of the pods that were changed. # @return [Set<String>] the names of the pods that were changed.
# #
attr_accessor :changed attr_accessor :changed
# @return [Array<String>] the names of the pods that were deleted. # @return [Set<String>] the names of the pods that were deleted.
# #
attr_accessor :deleted attr_accessor :deleted
# @return [Array<String>] the names of the pods that were unchanged. # @return [Set<String>] the names of the pods that were unchanged.
# #
attr_accessor :unchanged attr_accessor :unchanged
...@@ -68,7 +76,7 @@ module Pod ...@@ -68,7 +76,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_name(name, state) def add_name(name, state)
send(state) << name send(state) << Specification.root_name(name)
end end
end end
end end
......
...@@ -22,12 +22,12 @@ module Pod ...@@ -22,12 +22,12 @@ module Pod
@analyzer.stubs(:sandbox_checksum).returns(@spec.checksum) @analyzer.stubs(:sandbox_checksum).returns(@spec.checksum)
state = @analyzer.analyze state = @analyzer.analyze
state.class.should == Installer::Analyzer::SpecsState state.class.should == Installer::Analyzer::SpecsState
state.unchanged.should == ['BananaLib'] state.unchanged.should == Set.new(%w(BananaLib))
end end
it 'marks all the pods as added if no sandbox manifest is available' do it 'marks all the pods as added if no sandbox manifest is available' do
@sandbox.stubs(:manifest) @sandbox.stubs(:manifest)
@analyzer.analyze.added.should == ['BananaLib'] @analyzer.analyze.added.should == Set.new(%w(BananaLib))
end end
end end
......
...@@ -52,10 +52,10 @@ module Pod ...@@ -52,10 +52,10 @@ module Pod
it 'computes the state of the Podfile respect to the Lockfile' do it 'computes the state of the Podfile respect to the Lockfile' do
state = @analyzer.analyze.podfile_state state = @analyzer.analyze.podfile_state
state.added.should == %w(AFNetworking libextobjc/EXTKeyPathCoding libextobjc/EXTSynthesize) state.added.should == Set.new(%w(AFNetworking libextobjc libextobjc))
state.changed.should == %w() state.changed.should == Set.new(%w())
state.unchanged.should == %w(JSONKit SVPullToRefresh) state.unchanged.should == Set.new(%w(JSONKit SVPullToRefresh))
state.deleted.should == %w(NUI) state.deleted.should == Set.new(%w(NUI))
end end
#--------------------------------------# #--------------------------------------#
...@@ -437,7 +437,7 @@ module Pod ...@@ -437,7 +437,7 @@ module Pod
it 'does not download the same source multiple times for different subspecs' do it 'does not download the same source multiple times for different subspecs' do
podfile_state = Installer::Analyzer::SpecsState.new podfile_state = Installer::Analyzer::SpecsState.new
podfile_state.added << 'ARAnalytics/Mixpanel' << 'ARAnalytics/HockeyApp' podfile_state.added << 'ARAnalytics'
@analyzer.stubs(:result).returns(stub(:podfile_state => podfile_state)) @analyzer.stubs(:result).returns(stub(:podfile_state => podfile_state))
@podfile.stubs(:dependencies).returns([ @podfile.stubs(:dependencies).returns([
Dependency.new('ARAnalytics/Mixpanel', :git => 'https://github.com/orta/ARAnalytics', :commit => '6f1a1c314894437e7e5c09572c276e644dbfb64b'), Dependency.new('ARAnalytics/Mixpanel', :git => 'https://github.com/orta/ARAnalytics', :commit => '6f1a1c314894437e7e5c09572c276e644dbfb64b'),
......
...@@ -396,7 +396,7 @@ module Pod ...@@ -396,7 +396,7 @@ module Pod
it 'analyzes the Podfile, the Lockfile and the Sandbox' do it 'analyzes the Podfile, the Lockfile and the Sandbox' do
@installer.send(:analyze) @installer.send(:analyze)
@installer.analysis_result.sandbox_state.added.should == ['JSONKit'] @installer.analysis_result.sandbox_state.added.should == Set.new(%w(JSONKit))
end end
it 'stores the targets created by the analyzer' do it 'stores the targets created by the analyzer' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment