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