Browse files

Merge branch 'master' into pod_update

* master:
  [Git] Init submodules only after the checkout. #451
  [Subversion] Improved head support.
  [LocalPod] Completed fix for public headers handling. #449
  [LocalPod] Fix public headers handling. #449
  • Loading branch information...
2 parents ea632ad + a24144f commit 0a244e6e39f735b0b028b941ce405c792f6182e3 @fabiopelosin fabiopelosin committed Aug 9, 2012
View
19 lib/cocoapods/downloader/git.rb
@@ -30,7 +30,7 @@ def create_cache
puts "-> Creating cache git repo (#{cache_path})" if config.verbose?
cache_path.rmtree if cache_path.exist?
cache_path.mkpath
- clone(url, cache_path)
+ git %Q|clone "#{url}" "#{cache_path}"|
end
def prune_cache
@@ -95,7 +95,6 @@ def ensure_ref_exists(ref)
def ensure_remote_branch_exists(branch)
Dir.chdir(cache_path) { git "branch -r | grep #{branch}$" } # check for remote branch and do suffix matching ($ anchor)
return if $? == 0
-
raise Informative, "[!] Cache unable to find git reference `#{branch}' for `#{url}' (#{$?}).".red
end
@@ -105,7 +104,8 @@ def download_head
else
create_cache
end
- clone(clone_url, target_path)
+ git %Q|clone "#{clone_url}" "#{target_path}"|
+ Dir.chdir(target_path) { git "submodule update --init" }
end
def download_tag
@@ -122,27 +122,22 @@ def download_tag
def download_commit
ensure_ref_exists(options[:commit])
- clone(clone_url, target_path)
+ git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) do
git "checkout -b activated-pod-commit #{options[:commit]}"
+ git "submodule update --init"
end
end
def download_branch
ensure_remote_branch_exists(options[:branch])
- clone(clone_url, target_path)
+ git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) do
git "remote add upstream '#{@url}'" # we need to add the original url, not the cache url
git "fetch -q upstream" # refresh the branches
git "checkout --track -b activated-pod-commit upstream/#{options[:branch]}" # create a new tracking branch
- puts "Just downloaded and checked out branch: #{options[:branch]} from upstream #{clone_url}" if config.verbose?
- end
- end
-
- def clone(from, to)
- git "clone \"#{from}\" \"#{to}\""
- Dir.chdir(to) do
git "submodule update --init"
+ puts "Just downloaded and checked out branch: #{options[:branch]} from upstream #{clone_url}" if config.verbose?
end
end
end
View
25 lib/cocoapods/downloader/subversion.rb
@@ -4,25 +4,26 @@ class Subversion < Downloader
executable :svn
def download
- if options[:revision]
- download_revision
- elsif options[:tag]
- download_tag
- else
- download_head
- end
+ svn %|checkout "#{reference_url}" "#{target_path}"|
end
def download_head
- svn %|checkout "#{url}/#{options[:folder]}" "#{target_path}"|
+ svn %|checkout "#{trunk_url}" "#{target_path}"|
end
- def download_revision
- svn %|checkout "#{url}/#{options[:folder]}" -r "#{options[:revision]}" "#{target_path}"|
+ def reference_url
+ result = url.dup
+ result << '/' << options[:folder] if options[:folder]
+ result << '/tags/' << options[:tag] if options[:tag]
+ result << '" -r "' << options[:revision] if options[:revision]
+ result
end
- def download_tag
- svn %|checkout "#{url}/tags/#{options[:tag]}/#{options[:folder]}" "#{target_path}"|
+ def trunk_url
+ result = url.dup
+ result << '/' << options[:folder] if options[:folder]
+ result << '/trunk'
+ result
end
end
end
View
49 lib/cocoapods/local_pod.rb
@@ -231,21 +231,25 @@ def header_files_by_spec
result
end
- # @return [Hash{Specification => Array<Pathname>}] The paths of the public
- # header files grouped by {Specification}.
+ # @return [Hash{Specification => Array<Pathname>}] The paths of the header
+ # files grouped by {Specification} that should be copied in the public
+ # folder.
#
- # @TODO: complete, fix and comment
- # @TODO: decide a policy for subspecs
+ # If a spec does not match any public header it means that all the
+ # header files (i.e. the build ones) are intended to be public.
#
- def public_header_files_by_specs
- cached_header_files_by_spec = header_files_by_spec
- public_header_files = paths_by_spec(:source_files, :glob => '*.h')
+ def public_header_files_by_spec
+ public_headers = paths_by_spec(:public_header_files, :glob => '*.h')
+ build_headers = header_files_by_spec
result = {}
- public_header_files.map do |spec, paths|
- result[spec] = paths.empty? ? cached_header_files_by_spec[spec] : paths
+ specifications.each do |spec|
+ if (public_h = public_headers[spec]) && !public_h.empty?
+ result[spec] = public_h
+ elsif (build_h = build_headers[spec]) && !build_h.empty?
+ result[spec] = build_h
+ end
end
-
result
end
@@ -343,12 +347,13 @@ def all_specs_public_header_files
#
def link_headers
@sandbox.build_headers.add_search_path(headers_sandbox)
- header_mappings.each do |namespaced_path, files|
+ @sandbox.public_headers.add_search_path(headers_sandbox)
+
+ header_mappings(header_files_by_spec).each do |namespaced_path, files|
@sandbox.build_headers.add_files(namespaced_path, files)
end
- @sandbox.public_headers.add_search_path(headers_sandbox)
- public_header_mappings.each do |namespaced_path, files|
+ header_mappings(public_header_files_by_spec).each do |namespaced_path, files|
@sandbox.public_headers.add_files(namespaced_path, files)
end
end
@@ -401,23 +406,9 @@ def relative_root
#
# @todo This is not overridden anymore in specification refactor and the
# code Pod::Specification#copy_header_mapping can be moved here.
- def header_mappings
- mappings = {}
- header_files_by_spec.each do |spec, paths|
- paths = paths - headers_excluded_from_search_paths
- paths.each do |from|
- from_relative = from.relative_path_from(root)
- to = headers_sandbox + (spec.header_dir) + spec.copy_header_mapping(from_relative)
- (mappings[to.dirname] ||= []) << from
- end
- end
- mappings
- end
-
- # TODO: complete, fix and comment
- def public_header_mappings
+ def header_mappings(files_by_spec)
mappings = {}
- public_header_files_by_specs.each do |spec, paths|
+ files_by_spec.each do |spec, paths|
paths = paths - headers_excluded_from_search_paths
paths.each do |from|
from_relative = from.relative_path_from(root)
View
13 spec/functional/downloader_spec.rb
@@ -177,7 +177,7 @@ module Pod
(pod.root + 'test.txt').should.exist?
end
- it "doesn't updates cache the if the ref is available" do
+ it "doesn't update the cache if the ref is available" do
@pod.top_specification.stubs(:source).returns(
:git => fixture('banana-lib'), :commit => 'fd56054'
)
@@ -253,6 +253,7 @@ module Pod
end
describe "for Subversion" do
+
it "check's out a specific revision" do
@pod.top_specification.stubs(:source).returns(
:svn => "file://#{fixture('subversion-repo')}", :revision => '1'
@@ -270,8 +271,18 @@ module Pod
downloader.download
(@pod.root + 'README').read.strip.should == 'tag 1'
end
+
+ it "check's out the head version" do
+ @pod.top_specification.stubs(:source).returns(
+ :svn => "file://#{fixture('subversion-repo')}", :revision => '1'
+ )
+ downloader = Downloader.for_pod(@pod)
+ downloader.download_head
+ (@pod.root + 'README').read.strip.should == 'unintersting'
+ end
end
+
describe "for HTTP" do
extend SpecHelper::TemporaryDirectory
View
17 spec/unit/local_pod_spec.rb
@@ -278,7 +278,7 @@ def assert_array_equals(expected, computed)
end
it "returns a hash of mappings with a custom header dir prefix" do
- mappings = @pod.send(:header_mappings)
+ mappings = @pod.send(:header_mappings, @pod.header_files_by_spec)
mappings = mappings.map do |folder, headers|
"#{folder} > #{headers.sort.map{ |p| p.relative_path_from(@pod.root).to_s }.join(' ')}"
end
@@ -289,7 +289,7 @@ def assert_array_equals(expected, computed)
it "respects the headers excluded from the search paths" do
@pod.stubs(:headers_excluded_from_search_paths).returns([@pod.root + 'UIKit/Classes/UIKit.h'])
- mappings = @pod.send(:header_mappings)
+ mappings = @pod.send(:header_mappings, @pod.header_files_by_spec)
mappings = mappings.map do |folder, headers|
"#{folder} > #{headers.sort.map{ |p| p.relative_path_from(@pod.root).to_s }.join(' ')}"
end
@@ -298,11 +298,22 @@ def assert_array_equals(expected, computed)
"Chameleon/UIKit > UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h" ]
end
- # This is done by the sandbox and this test should be moved
+ # @TODO: This is done by the sandbox and this test should be moved
it "includes the sandbox of the pod's headers while linking" do
@sandbox.build_headers.expects(:add_search_path).with(Pathname.new('Chameleon'))
@sandbox.public_headers.expects(:add_search_path).with(Pathname.new('Chameleon'))
@pod.link_headers
end
+
+ it "differentiates among public and build headers" do
+ subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs
+ spec = subspecs[0]
+ spec.stubs(:public_header_files).returns("UIKit/Classes/*Kit.h")
+ @pod = Pod::LocalPod.new(spec, @sandbox, Pod::Platform.new(:osx))
+ build_headers = @pod.header_files_by_spec.values.flatten.map{ |p| p.basename.to_s }
+ public_headers = @pod.public_header_files_by_spec.values.flatten.map{ |p| p.basename.to_s }
+ build_headers.sort.should == %w{ UIKit.h UIView.h UIWindow.h }
+ public_headers.should == %w{ UIKit.h }
+ end
end
end

0 comments on commit 0a244e6

Please sign in to comment.