Commit 79fa28ac authored by Eloy Duran's avatar Eloy Duran

Clean up after downloading. In the case of git that means removing the .git dir from the clone.

parent 99819b9f
...@@ -3,7 +3,7 @@ module Pod ...@@ -3,7 +3,7 @@ module Pod
class Install < Command class Install < Command
def run def run
if spec = Specification.from_podfile(podfile) if spec = Specification.from_podfile(podfile)
spec.install_dependent_specifications!(pods_root) spec.install_dependent_specifications!(pods_root, true)
else else
$stderr.puts "No Podfile found in current working directory." $stderr.puts "No Podfile found in current working directory."
end end
......
module Pod module Pod
class Downloader class Downloader
def self.for_source(source) def self.for_source(source, pod_root)
options = source.dup options = source.dup
if url = options.delete(:git) if url = options.delete(:git)
Git.new(url, options) Git.new(pod_root, url, options)
else else
raise "Unsupported download strategy `#{source.inspect}'." raise "Unsupported download strategy `#{source.inspect}'."
end end
end end
def initialize(url, options) def initialize(pod_root, url, options)
@url, @options = url, options @pod_root, @url, @options = pod_root, url, options
end end
class Git < Downloader class Git < Downloader
...@@ -22,11 +22,14 @@ module Pod ...@@ -22,11 +22,14 @@ module Pod
# * sync output # * sync output
executable :git executable :git
def download_to(pod_root) def source_dir
checkout = pod_root + 'source' @pod_root + 'source'
end
def download
if tag = @options[:tag] if tag = @options[:tag]
checkout.mkdir source_dir.mkdir
Dir.chdir(checkout) do Dir.chdir(source_dir) do
git "init" git "init"
git "remote add origin '#{@url}'" git "remote add origin '#{@url}'"
git "fetch origin tags/#{tag} 2>&1" git "fetch origin tags/#{tag} 2>&1"
...@@ -34,14 +37,18 @@ module Pod ...@@ -34,14 +37,18 @@ module Pod
git "checkout -b activated-pod-commit 2>&1" git "checkout -b activated-pod-commit 2>&1"
end end
elsif commit = @options[:commit] elsif commit = @options[:commit]
git "clone '#{@url}' '#{checkout}'" git "clone '#{@url}' '#{source_dir}'"
Dir.chdir(checkout) do Dir.chdir(source_dir) do
git "checkout -b activated-pod-commit #{commit} 2>&1" git "checkout -b activated-pod-commit #{commit} 2>&1"
end end
else else
raise "Either a tag or a commit has to be specified." raise "Either a tag or a commit has to be specified."
end end
end end
def clean
(source_dir + '.git').rmtree
end
end end
end end
end end
...@@ -87,7 +87,7 @@ module Pod ...@@ -87,7 +87,7 @@ module Pod
@resolved_dependent_specifications ||= Resolver.new(self).resolve @resolved_dependent_specifications ||= Resolver.new(self).resolve
end end
def install_dependent_specifications!(root) def install_dependent_specifications!(root, clean)
resolved_dependent_specifications.each do |spec| resolved_dependent_specifications.each do |spec|
install_spec = spec install_spec = spec
if part_of_spec_dep = spec.read(:part_of) if part_of_spec_dep = spec.read(:part_of)
...@@ -96,12 +96,12 @@ module Pod ...@@ -96,12 +96,12 @@ module Pod
else else
puts "-- Installing: #{install_spec}" puts "-- Installing: #{install_spec}"
end end
install_spec.install!(root) install_spec.install!(root, clean)
end end
end end
# User can override this for custom installation # User can override this for custom installation
def install!(pods_root) def install!(pods_root, clean)
require 'fileutils' require 'fileutils'
pods_root.mkpath pods_root.mkpath
pod_root = pods_root + "#{@name}-#{@version}" pod_root = pods_root + "#{@name}-#{@version}"
...@@ -110,13 +110,15 @@ module Pod ...@@ -110,13 +110,15 @@ module Pod
else else
pod_root.mkdir pod_root.mkdir
FileUtils.cp(@defined_in_file, pod_root) FileUtils.cp(@defined_in_file, pod_root)
download_to(pod_root) download_to(pod_root, clean)
end end
end end
# User can override this for custom downloading # User can override this for custom downloading
def download_to(pod_root) def download_to(pod_root, clean)
Downloader.for_source(@source).download_to(pod_root) downloader = Downloader.for_source(@source, pod_root)
downloader.download
downloader.clean if clean
end end
def from_podfile? def from_podfile?
......
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