-
Notifications
You must be signed in to change notification settings - Fork 72
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
The downloader is no longer confused by params in the URL. #40
Conversation
Thanks for this pull request @mbishop-fiksu. Would you be able to add an entry for this in our CHANGELOG? Just an entry under a new version called |
I'd be happy to. |
Thx @mbishop-fiksu Does anyone know why specs aren't passing? Is it due to the fix or was it failing before? |
I added one test: I understand the error for the |
That's strange. On my side, your new spec passes, but otherwise the specs that fails on Travis also do fail locally on my machine (and bazaar-related specs fails too, but that's because I don't have bazaar installed so that's to be expected)
Maybe your fix has a side-effect of introducing regressions for other parts. But I mostly suspect that parsing the URL (which is the new thing you do in your code) failed in some cases for those specs. Maybe it is only related to a special case with
I use system Ruby (2.0.0p481) on Yosemite but tests aren't passing on my side, so that must be something else. |
Got it. The specs are using fake URLs that looks like We will have to fix the spec to use proper URLs to test the methods. |
@mbishop-fiksu I can't push onto your own repo to apply the fix but here is the diff. Can you please apply the modifications to it 'detects zip files' do
- options = { :http => 'https://file.zip' }
+ options = { :http => 'https://foo/file.zip' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :zip
end
it 'detects tar files' do
- options = { :http => 'https://file.tar' }
+ options = { :http => 'https://foo/file.tar' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :tar
end
it 'detects tgz files' do
- options = { :http => 'https://file.tgz' }
+ options = { :http => 'https://foo/file.tgz' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :tgz
end
it 'detects tbz files' do
- options = { :http => 'https://file.tbz' }
+ options = { :http => 'https://foo/file.tbz' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :tbz
end
it 'detects txz files' do
- options = { :http => 'https://file.txz' }
+ options = { :http => 'https://foo/file.txz' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :txz
end
it 'allows to specify the file type in the sources' do
- options = { :http => 'https://file', :type => :zip }
+ options = { :http => 'https://foo/file', :type => :zip }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :zip
end
it 'should download file and extract it with proper type' do
- options = { :http => 'https://file.zip' }
+ options = { :http => 'https://foo/file.zip' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.expects(:download_file).with(anything)
downloader.expects(:extract_with_type).with(anything, :zip).at_least_once
[...]
it 'should raise error when an unsupported file type is detected' do
- options = { :http => 'https://file.rar' }
+ options = { :http => 'https://foo/file.rar' }
downloader = Downloader.for_target(tmp_folder, options)
lambda { downloader.download }.should.raise Http::UnsupportedFileTypeError
end
it 'should raise error when an unsupported file type is specified in the options' do
- options = { :http => 'https://file', :type => :rar }
+ options = { :http => 'https://foo/file', :type => :rar }
downloader = Downloader.for_target(tmp_folder, options)
lambda { downloader.download }.should.raise Http::UnsupportedFileTypeError
end
it 'detects the file type if specified with a string' do
- options = { :http => 'https://file', :type => 'zip' }
+ options = { :http => 'https://foo/file', :type => 'zip' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :zip
end
it 'returns whether it does not supports the download of the head' do
- options = { :http => 'https://file', :type => 'zip' }
+ options = { :http => 'https://foo/file', :type => 'zip' }
downloader = Downloader.for_target(tmp_folder('checkout'), options)
downloader.head_supported?.should.be.false
end |
As for your added But anyway, the change that your patch does is to correctly detect the type of the file based on the extension in the URL, disregarding the params if any only in the type-detection method. So that's what you should only test, without even trying to download anything 😉 Like this for example: it 'detects zip files even when URL has params' do
options = { :http => 'https://foo/file.zip?param=value' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.send(:type).should == :zip
end Feel free to adapt. And thx again! |
Ok, thank you for all the suggestions. I'll apply the fixes... |
Note: why move to |
@kylef Do you know why Rubocop limits classes to 119 lines? I mean why 119?
|
When I added the 'foo' host, the specs didn't pass and since |
If specs didn't pass when you added the |
The only thing that is now failing is the RuboCop call. All tests use your suggestions verbatim. The http class is 164 lines. I don't think I can fix that up to pass RuboCop's test 😞 |
Thx! To pass the Rubocop we might have to split the class into multiple files and extract some methods into an utility class. But that may be sthg for another PR maybe. @kylef should we merge this (and open an issue to fix rubocop in another PR)? |
@AliSoftware I don’t like a proliferation of ‘util’ / ‘helper’ modules and especially not just to satisfy rubocop. This is simply a rule that I don’t feel adds anything for us, as such I have already disabled it on Xcodeproj: CocoaPods/Xcodeproj@6622aa1. Please do so here as well. |
Gotcha |
@alloy I disabled the offending rubocop rule in master. |
Sure! It's quite simple actually: In the terminal make sure you are in the directory where you cloned your fork, and that you are on your master branch, then run this command:
This will pull the new commit(s) from CocoaPods's original repo, rebasing your own commits on top of them (so GIT will replay (rebase) your commits on top of CP's new commits, instead of doing a merge). You will then have to force-push the changes on the remote (as rebasing typically rewrites history by removing commits and replaying them anew, with a new sha1):
|
116bbbc
to
5c2e682
Compare
done. Thanks @AliSoftware |
The downloader is no longer confused by params in the URL.
Thanks for this pull-request and the updates @mbishop-fiksu. |
Adding parameters to a specification's source URL confuses the downloader as it assumes the end of the url contains the file extension of the payload.
This change makes sure the file's extension is inferred from only the "path" part of the source url.