Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 14, 2016
Merged

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

merged 1 commit into from
Jun 14, 2016

Conversation

champo
Copy link
Contributor

@champo champo commented May 20, 2016

This adds the posibility of caches hits for git branch dependencies.
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.

Related to #5376

TODO

@@ -21,7 +21,7 @@ class Request

# @return [Hash<Symbol, String>] The download parameters for this request.
#
attr_reader :params
attr_accessor :params
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd rather keep Request immutable and just construct a new instance instead of mutating?

Copy link
Contributor Author

@champo champo May 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was torn on this. I agree that adding mutation here isn't the nicest thing. But it seemed weird to me that the request instance that's held by the user of the downloader would stop being "truthful". Looking at the call sites for Downloder.download the request is never even saved to a variable so I think I'll change it to be immutable again.

@segiddins
Copy link
Member

🎆 you can actually change the Gemfile to point to your branch for now so we can try this out :D

@champo
Copy link
Contributor Author

champo commented May 22, 2016

@segiddins done!

@champo
Copy link
Contributor Author

champo commented Jun 10, 2016

@segiddins I'm not sure how to go about adding tests for this, do you have any ideas?

@segiddins
Copy link
Member

In https://github.com/CocoaPods/CocoaPods/blob/master/spec/unit/downloader/cache_spec.rb, maybe just make sure the options are preprocessed?

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.
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@segiddins this is a bit out of scope in this PR but I stumbled across it writing the test. Does this seem right to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I recall this is because otherwise you don't know where to download to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly. I stumbled upon it throwing a random error farther down the call chain so I copied the check for cache_path.

I've added a simple test btw. Considering the coverage over at cocoapods-downloader I think this is enough, but I can add more if you disagree.

@segiddins
Copy link
Member

👍🏻
🚢

@segiddins segiddins merged commit 4856acb into CocoaPods:master Jun 14, 2016
@champo champo deleted the cache_git branch June 14, 2016 02:42
@talesp
Copy link

talesp commented Jun 20, 2016

I'm trying to use cocoapods right form the sources (setting my Gemfile as gem 'cocoapods', :git => 'https://github.com/CocoaPods/CocoaPods.git') because I want try the fix of the merge from #5503, since I'm getting the error The bundle “ishopMobileKitTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. with version 1.0.1.

But now I'm getting an error on pod install, and looks like the problem is caused by this merge.

NoMethodError - undefined methodpreprocess_options' for Pod::Downloader:Module`

preprocess_request calls preprocess_options, but I didn't find this method definition...

@talesp
Copy link

talesp commented Jun 20, 2016

Ok, nevermind, I added gem 'cocoapods-downloader', :git => 'https://github.com/CocoaPods/cocoapods-downloader.git' and the install was completed. My fault :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants