Skip to content

Commit

Permalink
Merge pull request #6497 from dnkoutso/warn_for_multiple_sources
Browse files Browse the repository at this point in the history
Provide installation option to disable multiple pod sources warnings
  • Loading branch information
dnkoutso committed Mar 8, 2017
2 parents 8a2c46a + e44c425 commit 697d780
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6534](https://github.com/CocoaPods/CocoaPods/issues/6534)

* Provide installation option to disable multiple pod sources warnings.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6497](https://github.com/CocoaPods/CocoaPods/pull/6497)

* Use the colored2 gem instead of colored.
[Orta Therox](https://github.com/orta)
[xcodeproj#463](https://github.com/CocoaPods/Xcodeproj/pull/463)
Expand Down
1 change: 1 addition & 0 deletions lib/cocoapods/installer/installation_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def hash
option :deterministic_uuids, true
option :integrate_targets, true
option :lock_pod_sources, true
option :warn_for_multiple_pod_sources, true
option :share_schemes_for_development_pods, false

module Mixin
Expand Down
6 changes: 5 additions & 1 deletion lib/cocoapods/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module Pod
# by target for a given Podfile.
#
class Resolver
include Pod::Installer::InstallationOptions::Mixin

delegate_installation_options { podfile }

# @return [Sandbox] the Sandbox used by the resolver to find external
# dependencies.
#
Expand Down Expand Up @@ -288,7 +292,7 @@ def indicate_progress
def specifications_for_dependency(dependency, additional_requirements = [])
requirement = Requirement.new(dependency.requirement.as_list + additional_requirements)
find_cached_set(dependency).
all_specifications.
all_specifications(installation_options.warn_for_multiple_pod_sources).
select { |s| requirement.satisfied_by? s.version }.
map { |s| s.subspec_by_name(dependency.name, false) }.
compact.
Expand Down
18 changes: 10 additions & 8 deletions lib/cocoapods/resolver/lazy_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,28 @@ def specification
end

class External
def all_specifications
def all_specifications(_warn_for_multiple_pod_sources)
[specification]
end
end

def all_specifications
def all_specifications(warn_for_multiple_pod_sources)
@all_specifications ||= begin
sources_by_version = {}
versions_by_source.each do |source, versions|
versions.each { |v| (sources_by_version[v] ||= []) << source }
sources_by_version
end

duplicate_versions = sources_by_version.select { |_version, sources| sources.count > 1 }
if warn_for_multiple_pod_sources
duplicate_versions = sources_by_version.select { |_version, sources| sources.count > 1 }

duplicate_versions.each do |version, sources|
UI.warn "Found multiple specifications for `#{name} (#{version})`:\n" +
sources.
map { |s| s.specification_path(name, version) }.
map { |v| "- #{v}" }.join("\n")
duplicate_versions.each do |version, sources|
UI.warn "Found multiple specifications for `#{name} (#{version})`:\n" +
sources.
map { |s| s.specification_path(name, version) }.
map { |v| "- #{v}" }.join("\n")
end
end

versions_by_source.flat_map do |source, versions|
Expand Down
1 change: 1 addition & 0 deletions spec/unit/installer/installation_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module Pod
'deterministic_uuids' => false,
'integrate_targets' => true,
'lock_pod_sources' => true,
'warn_for_multiple_pod_sources' => true,
'share_schemes_for_development_pods' => false,
}
end
Expand Down

0 comments on commit 697d780

Please sign in to comment.