Commit f49a5cec authored by François Benaiteau's avatar François Benaiteau Committed by Fabio Pelosin

[Resolver] Support for specification of sources

parent 79d2b1f6
...@@ -18,6 +18,14 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -18,6 +18,14 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[#1668](https://github.com/CocoaPods/CocoaPods/pull/1668) [#1668](https://github.com/CocoaPods/CocoaPods/pull/1668)
[#731](https://github.com/CocoaPods/CocoaPods/pull/731) [#731](https://github.com/CocoaPods/CocoaPods/pull/731)
* Added specific repo sources support. Allows to specify in podfile
which sources should be used to retrieve specs from and the priority
order. Example: `source 'netbe'`, or source 'master'. 'master' being
default github cocoapods specs repo.
[François Benaiteau](https://github.com/netbe)
[#1143](https://github.com/CocoaPods/CocoaPods/pull/1143)
[Core#19](https://github.com/CocoaPods/Core/pull/19)
* Added hooks for plugins. Currently only the installer hook is supported. * Added hooks for plugins. Currently only the installer hook is supported.
A plugin can register itself to be activated after the installation with the A plugin can register itself to be activated after the installation with the
following syntax: following syntax:
...@@ -101,6 +109,7 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -101,6 +109,7 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Fabio Pelosin][FabioPelosin] [Fabio Pelosin][FabioPelosin]
[#34](https://github.com/CocoaPods/CLAide/issues/34) [#34](https://github.com/CocoaPods/CLAide/issues/34)
## 0.33.0 ## 0.33.0
##### Breaking ##### Breaking
......
...@@ -169,9 +169,18 @@ module Pod ...@@ -169,9 +169,18 @@ module Pod
# #
def update_repositories_if_needed def update_repositories_if_needed
unless config.skip_repo_update? unless config.skip_repo_update?
sources = SourcesManager.podfile_sources
if sources.empty?
UI.section 'Updating spec repositories' do UI.section 'Updating spec repositories' do
SourcesManager.update SourcesManager.update
end end
else
sources.each do |source|
UI.section "Updating spec repository #{source}" do
SourcesManager.update(source)
end
end
end
end end
end end
......
...@@ -51,7 +51,7 @@ module Pod ...@@ -51,7 +51,7 @@ module Pod
# definition. # definition.
# #
def resolve def resolve
@cached_sources = SourcesManager.aggregate @cached_sources = SourcesManager.aggregate(true)
@cached_sets = {} @cached_sets = {}
@cached_specs = {} @cached_specs = {}
@specs_by_target = {} @specs_by_target = {}
......
...@@ -5,11 +5,30 @@ module Pod ...@@ -5,11 +5,30 @@ module Pod
class << self class << self
include Config::Mixin include Config::Mixin
# @return [Array<Source>] the sources listed by the current Podfile.
#
def podfile_sources
sources = []
self.podfile_repos_dirs.each do |repo|
sources << Source.new(repo)
end
sources << Source.new(master_repo_dir) if sources.empty?
sources
end
# @param [Bool] podfile use podfile sources
#
# @return [Source::Aggregate] the aggregate of all the sources known to # @return [Source::Aggregate] the aggregate of all the sources known to
# this installation of CocoaPods. # this installation of CocoaPods.
# #
def aggregate def aggregate(podfile = false)
Source::Aggregate.new(config.repos_dir) if podfile
repos = podfile_repos_dirs
else
repos = config.repos_dir.children.select(&:directory?)
end
Source::Aggregate.new(repos)
end end
# @return [Array<Source>] the list of all the sources known to this # @return [Array<Source>] the list of all the sources known to this
...@@ -287,6 +306,9 @@ module Pod ...@@ -287,6 +306,9 @@ module Pod
master_repo_dir.exist? && repo_compatible?(master_repo_dir) master_repo_dir.exist? && repo_compatible?(master_repo_dir)
end end
public
# @!group Source repos
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private private
...@@ -324,6 +346,25 @@ module Pod ...@@ -324,6 +346,25 @@ module Pod
git_repo?(source.data_provider.repo) git_repo?(source.data_provider.repo)
end end
end end
# @return [Array<Pathname>] directories of all specified sources in
# Podfile
#
def podfile_repos_dirs
pathnames = []
if config.podfile
config.podfile.sources.each do |source_name|
pathnames << source_repo_dir(source_name)
end
end
pathnames
end
# @return [Pathname] the directory where a given CocoaPods source is stored.
#
def source_repo_dir(name)
config.repos_dir + name
end
end end
end end
end end
...@@ -468,7 +468,30 @@ module Pod ...@@ -468,7 +468,30 @@ module Pod
end end
#--------------------------------------# #--------------------------------------#
describe "#update_repositories_if_needed" do
it "updates the podfile repositories" do
config.skip_repo_update = false
def @podfile.sources
["netbe", "master"]
end
SourcesManager.expects(:update).with("netbe").once
SourcesManager.expects(:update).with("master").once
@analyzer.send(:update_repositories_if_needed)
end
it "updates the default repositories" do
config.skip_repo_update = false
def @podfile.sources
[]
end
SourcesManager.expects(:update).once
@analyzer.send(:update_repositories_if_needed)
end
end
end end
end end
end end
...@@ -105,6 +105,22 @@ module Pod ...@@ -105,6 +105,22 @@ module Pod
path = SourcesManager.search_index_path.to_s path = SourcesManager.search_index_path.to_s
path.should.match %r[Library/Caches/CocoaPods/search_index.yaml] path.should.match %r[Library/Caches/CocoaPods/search_index.yaml]
end end
it "returns the sources from podfile" do
@podfile = Podfile.new do
platform :ios
source 'netbe'
source 'cocoapods'
end
SourcesManager.config.stubs(:podfile).returns(@podfile)
sources = SourcesManager.podfile_sources
sources.map(&:name).should == %w[netbe cocoapods]
end
it "returns cocoapods source if none specified" do
sources = SourcesManager.podfile_sources
sources.map(&:name).should == %w[master]
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
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