Commit 3c230cf0 authored by Juan Pablo Civile's avatar Juan Pablo Civile

[Cache] Use `git ls-remote` to skip full clones for branch dependencies

This adds the posibility of caches hits for git branch depedencies.
Previously, since pods didn't know the commit the branch points it
always did a full clone of the repo. Using `ls-remote` we can check the
commit the branch points to and reuse cached version of the pods if
available.
parent 877249a5
......@@ -12,6 +12,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Peter Ryszkiewicz](https://github.com/pRizz)
[#5414](https://github.com/CocoaPods/CocoaPods/pull/5414)
* Use `git ls-remote` to skip full clones for branch dependencies.
[Juan Civile](https://github.com/champo)
[#5376](https://github.com/CocoaPods/CocoaPods/issues/5376)
##### Bug Fixes
* Fix installing pods with `use_frameworks` when deduplication is disabled.
......
......@@ -41,7 +41,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/cocoapods-downloader.git
revision: 272c56dbde497a48a7310098989ed25d0cc0bc6d
revision: 0803d2280c14347e03cc5753efdca04e3697552c
branch: master
specs:
cocoapods-downloader (1.0.0)
......
......@@ -33,11 +33,16 @@ module Pod
cache_path: Config.instance.cache_root + 'Pods'
)
can_cache &&= !Config.instance.skip_download_cache
request = preprocess_request(request)
if can_cache
raise ArgumentError, 'Must provide a `cache_path` when caching.' unless cache_path
cache = Cache.new(cache_path)
result = cache.download_pod(request)
else
raise ArgumentError, 'Must provide a `target` when caching is disabled.' unless target
require 'cocoapods/installer/pod_source_preparer'
result, = download_request(request, target)
Installer::PodSourcePreparer.new(result.spec, result.location).prepare!
......@@ -110,6 +115,21 @@ module Pod
end
end
# Return a new request after preprocessing by the downloader
#
# @param [Request] request
# the request that needs preprocessing
#
# @return [Request] the preprocessed request
#
def self.preprocess_request(request)
Request.new(
:spec => request.spec,
:released => request.released_pod?,
:name => request.name,
:params => Downloader.preprocess_options(request.params))
end
public
class DownloaderError; include CLAide::InformativeError; end
......
......@@ -124,6 +124,7 @@ module Pod
def cached_pod(request)
cached_spec = cached_spec(request)
path = path_for_pod(request)
return unless cached_spec && path.directory?
spec = request.spec || cached_spec
Response.new(path, spec, request.params)
......
require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Downloader do
before do
@target_path = Pathname.new(Dir.mktmpdir)
source = { :git => SpecHelper.fixture('banana-lib'), :branch => 'master' }
@request = Downloader::Request.new(:name => 'BananaLib', :params => source)
end
after do
@target_path.rmtree if @target_path.directory?
end
it 'preprocesses requests' do
Downloader.expects(:preprocess_request).returns(@request)
Downloader.download(@request, @target_path, :can_cache => false)
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