diff --git a/lib/cocoapods-core/lockfile.rb b/lib/cocoapods-core/lockfile.rb index 1aa843d96..d75ff7342 100644 --- a/lib/cocoapods-core/lockfile.rb +++ b/lib/cocoapods-core/lockfile.rb @@ -135,18 +135,21 @@ def dependencies # # @return [Dependency] the generated dependency. # - def dependency_to_lock_pod_named(name) - dep = dependencies.find { |d| d.name == name || d.root_name == name } - version = version(name) - - unless dep && version + def dependencies_to_lock_pod_named(name) + result = [] + deps = dependencies.select { |d| d.root_name == name } + if deps.empty? raise StandardError, "Attempt to lock the `#{name}` Pod without an " \ 'known dependency.' end - locked_dependency = dep.dup - locked_dependency.specific_version = version - locked_dependency + deps.each do |dep| + version = version(dep.name) + locked_dependency = dep.dup + locked_dependency.specific_version = version + result << locked_dependency + end + result end # @return [Version] The version of CocoaPods which generated this lockfile. @@ -233,8 +236,8 @@ def detect_changes_with_podfile(podfile) [:added, :changed, :removed, :unchanged].each { |k| result[k] = [] } installed_deps = dependencies.map do |dep| - dependency_to_lock_pod_named(dep.name) - end + dependencies_to_lock_pod_named(dep.name) + end.flatten all_dep_names = (dependencies + podfile.dependencies).map(&:name).uniq all_dep_names.each do |name| installed_dep = installed_deps.find { |d| d.name == name } diff --git a/spec/lockfile_spec.rb b/spec/lockfile_spec.rb index 863556067..bb5e52694 100644 --- a/spec/lockfile_spec.rb +++ b/spec/lockfile_spec.rb @@ -143,12 +143,13 @@ def self.specs it 'returns the dependency that locks the pod with the given name to the installed version' do json_dep = Dependency.new('JSONKit', '1.4') json_dep.external_source = { :podspec => 'path/JSONKit.podspec' } - @lockfile.dependency_to_lock_pod_named('JSONKit').should == json_dep + result = @lockfile.dependencies_to_lock_pod_named('JSONKit') + result.should == [json_dep] end it 'raises if there is a request for a locking dependency for a not stored Pod' do should.raise StandardError do - @lockfile.dependency_to_lock_pod_named('Missing') + @lockfile.dependencies_to_lock_pod_named('Missing') end.message.should.match /without an known dependency/ end