Commit e45d24e2 authored by Fabio Pelosin's avatar Fabio Pelosin

[Sandbox] Store list of pods in head mode

Closes #1046
Closes #1039
parent 9577c6d3
...@@ -68,6 +68,9 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -68,6 +68,9 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
* Fix copy resources script for iOS < 6 and OS X < 10.8 by removing the * Fix copy resources script for iOS < 6 and OS X < 10.8 by removing the
`--reference-external-strings-file` `--reference-external-strings-file`
flag. [#1030](https://github.com/CocoaPods/CocoaPods/pull/1030) flag. [#1030](https://github.com/CocoaPods/CocoaPods/pull/1030)
* Fixed issues with the `:head` option of the Podfile.
[#1046](https://github.com/CocoaPods/CocoaPods/issues/1046)
[#1039](https://github.com/CocoaPods/CocoaPods/issues/1039)
## 0.19.1 ## 0.19.1
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.19.0...0.19.1) [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.19.0...0.19.1)
......
...@@ -151,7 +151,7 @@ module Pod ...@@ -151,7 +151,7 @@ module Pod
return true if sandbox.predownloaded?(pod) return true if sandbox.predownloaded?(pod)
return true if folder_empty?(pod) return true if folder_empty?(pod)
if update_mode if update_mode
return true if spec.version.head? return true if sandbox.head_pod?(pod)
end end
return false return false
end end
......
...@@ -91,7 +91,7 @@ module Pod ...@@ -91,7 +91,7 @@ module Pod
# #
def download_source def download_source
root.rmtree if root.exist? root.rmtree if root.exist?
if root_spec.version.head? if head_pod?
downloader.download_head downloader.download_head
@specific_source = downloader.checkout_options @specific_source = downloader.checkout_options
else else
...@@ -172,6 +172,10 @@ module Pod ...@@ -172,6 +172,10 @@ module Pod
sandbox.local?(root_spec.name) sandbox.local?(root_spec.name)
end end
def head_pod?
sandbox.head_pod?(root_spec.name)
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private private
......
...@@ -158,7 +158,10 @@ module Pod ...@@ -158,7 +158,10 @@ module Pod
@loaded_specs << spec.name @loaded_specs << spec.name
cached_specs[spec.name] = spec cached_specs[spec.name] = spec
validate_platform(spec, target_definition) validate_platform(spec, target_definition)
spec.version.head = dependency.head? if dependency.head? || sandbox.head_pod?(spec.name)
spec.version.head = true
sandbox.store_head_pod(spec.name)
end
spec_dependencies = spec.all_dependencies(target_definition.platform) spec_dependencies = spec.all_dependencies(target_definition.platform)
find_dependency_specs(spec, spec_dependencies, target_definition) find_dependency_specs(spec, spec_dependencies, target_definition)
......
...@@ -70,6 +70,7 @@ module Pod ...@@ -70,6 +70,7 @@ module Pod
@build_headers = HeadersStore.new(self, "BuildHeaders") @build_headers = HeadersStore.new(self, "BuildHeaders")
@public_headers = HeadersStore.new(self, "Headers") @public_headers = HeadersStore.new(self, "Headers")
@predownloaded_pods = [] @predownloaded_pods = []
@head_pods = []
@checkout_sources = {} @checkout_sources = {}
@local_pods = {} @local_pods = {}
FileUtils.mkdir_p(@root) FileUtils.mkdir_p(@root)
...@@ -94,8 +95,9 @@ module Pod ...@@ -94,8 +95,9 @@ module Pod
root.rmtree root.rmtree
end end
# Removes the files of the Pod with the given name from the sandbox.
# #
# # @return [void]
# #
def clean_pod(name) def clean_pod(name)
root_name = Specification.root_name(name) root_name = Specification.root_name(name)
...@@ -279,6 +281,37 @@ module Pod ...@@ -279,6 +281,37 @@ module Pod
#--------------------------------------# #--------------------------------------#
# Marks a Pod as head.
#
# @param [String] name
# The name of the Pod.
#
# @return [void]
#
def store_head_pod(name)
root_name = Specification.root_name(name)
head_pods << root_name
end
# @return [Array<String>] The names of the pods that have been
# marked as head.
#
attr_reader :head_pods
# Checks if a Pod should attempt to use the head source of the git repo.
#
# @param [String] name
# The name of the Pod.
#
# @return [Bool] Whether the Pod has been marked as head.
#
def head_pod?(name)
root_name = Specification.root_name(name)
head_pods.include?(root_name)
end
#--------------------------------------#
# Stores the local path of a Pod. # Stores the local path of a Pod.
# #
# @param [String] name # @param [String] name
......
...@@ -89,13 +89,13 @@ module Pod ...@@ -89,13 +89,13 @@ module Pod
end end
it "considers changed a Pod whose specification is in head mode if in update mode" do it "considers changed a Pod whose specification is in head mode if in update mode" do
@spec.version.head = true @sandbox.stubs(:head_pod?).returns(true)
@analyzer.stubs(:update_mode).returns(true) @analyzer.stubs(:update_mode).returns(true)
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
it "doesn't consider changed a Pod whose specification is in head mode if not in update mode" do it "doesn't consider changed a Pod whose specification is in head mode if not in update mode" do
@spec.version.head = true @sandbox.stubs(:head_pod?).returns(true)
@analyzer.stubs(:update_mode).returns(false) @analyzer.stubs(:update_mode).returns(false)
@analyzer.send(:pod_changed?, 'BananaLib').should == false @analyzer.send(:pod_changed?, 'BananaLib').should == false
end end
......
...@@ -34,7 +34,7 @@ module Pod ...@@ -34,7 +34,7 @@ module Pod
end end
it "downloads the head source if specified source" do it "downloads the head source if specified source" do
@spec.version.head = true config.sandbox.store_head_pod('BananaLib')
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' } @spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install! @installer.install!
@installer.specific_source[:commit].should == "0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc" @installer.specific_source[:commit].should == "0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc"
...@@ -51,7 +51,7 @@ module Pod ...@@ -51,7 +51,7 @@ module Pod
end end
it "stores the checkout options in the sandbox" do it "stores the checkout options in the sandbox" do
@spec.version.head = true config.sandbox.store_head_pod('BananaLib')
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' } @spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install! @installer.install!
sources = @installer.sandbox.checkout_sources sources = @installer.sandbox.checkout_sources
......
...@@ -161,6 +161,8 @@ module Pod ...@@ -161,6 +161,8 @@ module Pod
filemd5hash, jsonkit = resolver.resolve.values.first.sort_by(&:name) filemd5hash, jsonkit = resolver.resolve.values.first.sort_by(&:name)
filemd5hash.version.should.not.be.head filemd5hash.version.should.not.be.head
jsonkit.version.should.be.head jsonkit.version.should.be.head
config.sandbox.head_pod?('FileMD5Hash').should.be.false
config.sandbox.head_pod?('JSONKit').should.be.true
end end
it "raises if it finds two conflicting dependencies" do it "raises if it finds two conflicting dependencies" do
......
...@@ -76,6 +76,11 @@ module Pod ...@@ -76,6 +76,11 @@ module Pod
@sandbox.pod_dir('JSONKit').should == temporary_directory + 'Sandbox/JSONKit' @sandbox.pod_dir('JSONKit').should == temporary_directory + 'Sandbox/JSONKit'
end end
it "returns the directory where a local Pod is stored" do
@sandbox.store_local_path('BananaLib', Pathname.new('Some Path'))
@sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path')
end
it "returns the directory where to store the documentation" do it "returns the directory where to store the documentation" do
@sandbox.documentation_dir.should == temporary_directory + 'Sandbox/Documentation' @sandbox.documentation_dir.should == temporary_directory + 'Sandbox/Documentation'
end end
...@@ -122,23 +127,11 @@ module Pod ...@@ -122,23 +127,11 @@ module Pod
describe "Pods information" do describe "Pods information" do
it "returns the directory where a local Pod is stored" do
@sandbox.store_local_path('BananaLib', Pathname.new('Some Path'))
@sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path')
end
#--------------------------------------#
it "stores the list of the names of the pre-downloaded pods" do it "stores the list of the names of the pre-downloaded pods" do
@sandbox.store_pre_downloaded_pod('BananaLib') @sandbox.store_pre_downloaded_pod('BananaLib')
@sandbox.predownloaded_pods.should == ['BananaLib'] @sandbox.predownloaded_pods.should == ['BananaLib']
end end
it "returns the checkout sources of the Pods" do
@sandbox.store_pre_downloaded_pod('BananaLib/Subspec')
@sandbox.predownloaded_pods.should == ['BananaLib']
end
it "returns whether a Pod has been pre-downloaded" do it "returns whether a Pod has been pre-downloaded" do
@sandbox.predownloaded_pods << 'BananaLib' @sandbox.predownloaded_pods << 'BananaLib'
@sandbox.predownloaded?('BananaLib').should.be.true @sandbox.predownloaded?('BananaLib').should.be.true
...@@ -148,6 +141,25 @@ module Pod ...@@ -148,6 +141,25 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "stores the list of the names of the pre-downloaded pods" do
@sandbox.store_head_pod('BananaLib')
@sandbox.head_pods.should == ['BananaLib']
end
it "returns whether a Pod has been pre-downloaded" do
@sandbox.head_pods << 'BananaLib'
@sandbox.head_pod?('BananaLib').should.be.true
@sandbox.head_pod?('BananaLib/Subspec').should.be.true
@sandbox.head_pod?('Monkey').should.be.false
end
#--------------------------------------#
it "returns the checkout sources of the Pods" do
@sandbox.store_pre_downloaded_pod('BananaLib/Subspec')
@sandbox.predownloaded_pods.should == ['BananaLib']
end
it "stores the checkout source of a Pod" do it "stores the checkout source of a Pod" do
source = {:git => 'example.com', :commit => 'SHA'} source = {:git => 'example.com', :commit => 'SHA'}
@sandbox.store_checkout_source('BananaLib/Subspec', source ) @sandbox.store_checkout_source('BananaLib/Subspec', source )
......
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