Commit 9838d174 authored by Fabio Pelosin's avatar Fabio Pelosin

Enable caching for specs and remove configurable git cache size.

parent f03ed11c
...@@ -28,7 +28,6 @@ module Pod ...@@ -28,7 +28,6 @@ module Pod
@repos_dir = Pathname.new(File.expand_path("~/.cocoapods")) @repos_dir = Pathname.new(File.expand_path("~/.cocoapods"))
@verbose = @silent = @force_doc = false @verbose = @silent = @force_doc = false
@clean = @generate_docs = @doc_install = @integrate_targets = true @clean = @generate_docs = @doc_install = @integrate_targets = true
@git_cache_size = 500
end end
def project_root def project_root
......
...@@ -9,6 +9,8 @@ module Pod ...@@ -9,6 +9,8 @@ module Pod
include Config::Mixin include Config::Mixin
executable :git executable :git
MAX_CACHE_SIZE = 500
def download def download
prepare_cache prepare_cache
puts '->'.green << ' Cloning git repo' if config.verbose? puts '->'.green << ' Cloning git repo' if config.verbose?
...@@ -23,7 +25,7 @@ module Pod ...@@ -23,7 +25,7 @@ module Pod
end end
def prepare_cache def prepare_cache
unless cache_exist? || config.git_cache_size == 0 unless cache_exist?
puts '->'.green << " Creating cache git repo (#{cache_path})" if config.verbose? puts '->'.green << " 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
...@@ -35,7 +37,7 @@ module Pod ...@@ -35,7 +37,7 @@ module Pod
return unless caches_dir.exist? return unless caches_dir.exist?
Dir.chdir(caches_dir) do Dir.chdir(caches_dir) do
repos = Pathname.new(caches_dir).children.select { |c| c.directory? }.sort_by(&:ctime) repos = Pathname.new(caches_dir).children.select { |c| c.directory? }.sort_by(&:ctime)
while caches_size >= config.git_cache_size && !repos.empty? while caches_size >= MAX_CACHE_SIZE && !repos.empty?
dir = repos.shift dir = repos.shift
puts '->'.yellow << " Removing git cache for `#{origin_url(dir)}'" if config.verbose? puts '->'.yellow << " Removing git cache for `#{origin_url(dir)}'" if config.verbose?
dir.rmtree dir.rmtree
...@@ -60,8 +62,7 @@ module Pod ...@@ -60,8 +62,7 @@ module Pod
end end
def clone_url def clone_url
# git_cache_size = 0 disables the cache cache_path
config.git_cache_size == 0 ? url : cache_path
end end
def caches_size def caches_size
...@@ -70,7 +71,6 @@ module Pod ...@@ -70,7 +71,6 @@ module Pod
end end
def update_cache def update_cache
return if config.git_cache_size == 0
puts '->'.green << " Updating cache git repo (#{cache_path})" if config.verbose? puts '->'.green << " Updating cache git repo (#{cache_path})" if config.verbose?
Dir.chdir(cache_path) do Dir.chdir(cache_path) do
git "reset --hard HEAD" git "reset --hard HEAD"
...@@ -80,7 +80,6 @@ module Pod ...@@ -80,7 +80,6 @@ module Pod
end end
def ensure_ref_exists(ref) def ensure_ref_exists(ref)
return if config.git_cache_size == 0
Dir.chdir(cache_path) { git "rev-list --max-count=1 #{ref}" } Dir.chdir(cache_path) { git "rev-list --max-count=1 #{ref}" }
return if $? == 0 return if $? == 0
# Skip pull if not needed # Skip pull if not needed
......
...@@ -53,7 +53,6 @@ end ...@@ -53,7 +53,6 @@ end
config = Pod::Config.instance config = Pod::Config.instance
config.silent = true config.silent = true
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
config.git_cache_size = 0
require 'tmpdir' require 'tmpdir'
......
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