Commit 0a244e6e authored by Fabio Pelosin's avatar Fabio Pelosin

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
parents ea632ada a24144fb
...@@ -30,7 +30,7 @@ module Pod ...@@ -30,7 +30,7 @@ module Pod
puts "-> Creating cache git repo (#{cache_path})" if config.verbose? puts "-> Creating cache git repo (#{cache_path})" if config.verbose?
cache_path.rmtree if cache_path.exist? cache_path.rmtree if cache_path.exist?
cache_path.mkpath cache_path.mkpath
clone(url, cache_path) git %Q|clone "#{url}" "#{cache_path}"|
end end
def prune_cache def prune_cache
...@@ -95,7 +95,6 @@ module Pod ...@@ -95,7 +95,6 @@ module Pod
def ensure_remote_branch_exists(branch) def ensure_remote_branch_exists(branch)
Dir.chdir(cache_path) { git "branch -r | grep #{branch}$" } # check for remote branch and do suffix matching ($ anchor) Dir.chdir(cache_path) { git "branch -r | grep #{branch}$" } # check for remote branch and do suffix matching ($ anchor)
return if $? == 0 return if $? == 0
raise Informative, "[!] Cache unable to find git reference `#{branch}' for `#{url}' (#{$?}).".red raise Informative, "[!] Cache unable to find git reference `#{branch}' for `#{url}' (#{$?}).".red
end end
...@@ -105,7 +104,8 @@ module Pod ...@@ -105,7 +104,8 @@ module Pod
else else
create_cache create_cache
end end
clone(clone_url, target_path) git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) { git "submodule update --init" }
end end
def download_tag def download_tag
...@@ -122,27 +122,22 @@ module Pod ...@@ -122,27 +122,22 @@ module Pod
def download_commit def download_commit
ensure_ref_exists(options[:commit]) ensure_ref_exists(options[:commit])
clone(clone_url, target_path) git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) do Dir.chdir(target_path) do
git "checkout -b activated-pod-commit #{options[:commit]}" git "checkout -b activated-pod-commit #{options[:commit]}"
git "submodule update --init"
end end
end end
def download_branch def download_branch
ensure_remote_branch_exists(options[:branch]) ensure_remote_branch_exists(options[:branch])
clone(clone_url, target_path) git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) do Dir.chdir(target_path) do
git "remote add upstream '#{@url}'" # we need to add the original url, not the cache url git "remote add upstream '#{@url}'" # we need to add the original url, not the cache url
git "fetch -q upstream" # refresh the branches git "fetch -q upstream" # refresh the branches
git "checkout --track -b activated-pod-commit upstream/#{options[:branch]}" # create a new tracking branch 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" git "submodule update --init"
puts "Just downloaded and checked out branch: #{options[:branch]} from upstream #{clone_url}" if config.verbose?
end end
end end
end end
......
...@@ -4,25 +4,26 @@ module Pod ...@@ -4,25 +4,26 @@ module Pod
executable :svn executable :svn
def download def download
if options[:revision] svn %|checkout "#{reference_url}" "#{target_path}"|
download_revision
elsif options[:tag]
download_tag
else
download_head
end
end end
def download_head def download_head
svn %|checkout "#{url}/#{options[:folder]}" "#{target_path}"| svn %|checkout "#{trunk_url}" "#{target_path}"|
end end
def download_revision def reference_url
svn %|checkout "#{url}/#{options[:folder]}" -r "#{options[:revision]}" "#{target_path}"| 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 end
def download_tag def trunk_url
svn %|checkout "#{url}/tags/#{options[:tag]}/#{options[:folder]}" "#{target_path}"| result = url.dup
result << '/' << options[:folder] if options[:folder]
result << '/trunk'
result
end end
end end
end end
......
...@@ -231,21 +231,25 @@ module Pod ...@@ -231,21 +231,25 @@ module Pod
result result
end end
# @return [Hash{Specification => Array<Pathname>}] The paths of the public # @return [Hash{Specification => Array<Pathname>}] The paths of the header
# header files grouped by {Specification}. # files grouped by {Specification} that should be copied in the public
# folder.
# #
# @TODO: complete, fix and comment # If a spec does not match any public header it means that all the
# @TODO: decide a policy for subspecs # header files (i.e. the build ones) are intended to be public.
# #
def public_header_files_by_specs def public_header_files_by_spec
cached_header_files_by_spec = header_files_by_spec public_headers = paths_by_spec(:public_header_files, :glob => '*.h')
public_header_files = paths_by_spec(:source_files, :glob => '*.h') build_headers = header_files_by_spec
result = {} result = {}
public_header_files.map do |spec, paths| specifications.each do |spec|
result[spec] = paths.empty? ? cached_header_files_by_spec[spec] : paths 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 end
result result
end end
...@@ -343,12 +347,13 @@ module Pod ...@@ -343,12 +347,13 @@ module Pod
# #
def link_headers def link_headers
@sandbox.build_headers.add_search_path(headers_sandbox) @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) @sandbox.build_headers.add_files(namespaced_path, files)
end end
@sandbox.public_headers.add_search_path(headers_sandbox) header_mappings(public_header_files_by_spec).each do |namespaced_path, files|
public_header_mappings.each do |namespaced_path, files|
@sandbox.public_headers.add_files(namespaced_path, files) @sandbox.public_headers.add_files(namespaced_path, files)
end end
end end
...@@ -401,23 +406,9 @@ module Pod ...@@ -401,23 +406,9 @@ module Pod
# #
# @todo This is not overridden anymore in specification refactor and the # @todo This is not overridden anymore in specification refactor and the
# code Pod::Specification#copy_header_mapping can be moved here. # code Pod::Specification#copy_header_mapping can be moved here.
def header_mappings def header_mappings(files_by_spec)
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
mappings = {} 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 = paths - headers_excluded_from_search_paths
paths.each do |from| paths.each do |from|
from_relative = from.relative_path_from(root) from_relative = from.relative_path_from(root)
......
...@@ -177,7 +177,7 @@ module Pod ...@@ -177,7 +177,7 @@ module Pod
(pod.root + 'test.txt').should.exist? (pod.root + 'test.txt').should.exist?
end 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( @pod.top_specification.stubs(:source).returns(
:git => fixture('banana-lib'), :commit => 'fd56054' :git => fixture('banana-lib'), :commit => 'fd56054'
) )
...@@ -253,6 +253,7 @@ module Pod ...@@ -253,6 +253,7 @@ module Pod
end end
describe "for Subversion" do describe "for Subversion" do
it "check's out a specific revision" do it "check's out a specific revision" do
@pod.top_specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:svn => "file://#{fixture('subversion-repo')}", :revision => '1' :svn => "file://#{fixture('subversion-repo')}", :revision => '1'
...@@ -270,8 +271,18 @@ module Pod ...@@ -270,8 +271,18 @@ module Pod
downloader.download downloader.download
(@pod.root + 'README').read.strip.should == 'tag 1' (@pod.root + 'README').read.strip.should == 'tag 1'
end 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 end
describe "for HTTP" do describe "for HTTP" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
......
...@@ -278,7 +278,7 @@ describe Pod::LocalPod do ...@@ -278,7 +278,7 @@ describe Pod::LocalPod do
end end
it "returns a hash of mappings with a custom header dir prefix" do 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| mappings = mappings.map do |folder, headers|
"#{folder} > #{headers.sort.map{ |p| p.relative_path_from(@pod.root).to_s }.join(' ')}" "#{folder} > #{headers.sort.map{ |p| p.relative_path_from(@pod.root).to_s }.join(' ')}"
end end
...@@ -289,7 +289,7 @@ describe Pod::LocalPod do ...@@ -289,7 +289,7 @@ describe Pod::LocalPod do
it "respects the headers excluded from the search paths" do it "respects the headers excluded from the search paths" do
@pod.stubs(:headers_excluded_from_search_paths).returns([@pod.root + 'UIKit/Classes/UIKit.h']) @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| mappings = mappings.map do |folder, headers|
"#{folder} > #{headers.sort.map{ |p| p.relative_path_from(@pod.root).to_s }.join(' ')}" "#{folder} > #{headers.sort.map{ |p| p.relative_path_from(@pod.root).to_s }.join(' ')}"
end end
...@@ -298,11 +298,22 @@ describe Pod::LocalPod do ...@@ -298,11 +298,22 @@ describe Pod::LocalPod do
"Chameleon/UIKit > UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h" ] "Chameleon/UIKit > UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h" ]
end 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 it "includes the sandbox of the pod's headers while linking" do
@sandbox.build_headers.expects(:add_search_path).with(Pathname.new('Chameleon')) @sandbox.build_headers.expects(:add_search_path).with(Pathname.new('Chameleon'))
@sandbox.public_headers.expects(:add_search_path).with(Pathname.new('Chameleon')) @sandbox.public_headers.expects(:add_search_path).with(Pathname.new('Chameleon'))
@pod.link_headers @pod.link_headers
end 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
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