diff --git a/CHANGELOG.md b/CHANGELOG.md index b70437c..04ea70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog +## Master + ## 0.7.2 +* Fixed fetching from 'dumb' git remotes that don't support shallow clones. + [Michael Bishop](https://github.com/mbishop-fiksu) + [#40](https://github.com/CocoaPods/cocoapods-downloader/pull/40) ###### Enhancements diff --git a/Rakefile b/Rakefile index 2626f25..742d237 100644 --- a/Rakefile +++ b/Rakefile @@ -98,7 +98,7 @@ begin rescue LoadError $stderr.puts "\033[0;31m" \ '[!] Some Rake tasks haven been disabled because the environment' \ - ' couldn’t be loaded. Be sure to run `rake bootstrap` first.' \ + ' couldn\'t be loaded. Be sure to run `rake bootstrap` first.' \ "\e[0m" $stderr.puts e.message $stderr.puts e.backtrace diff --git a/lib/cocoapods-downloader/http.rb b/lib/cocoapods-downloader/http.rb index cdca333..581e6da 100644 --- a/lib/cocoapods-downloader/http.rb +++ b/lib/cocoapods-downloader/http.rb @@ -51,15 +51,16 @@ def should_flatten? end def type_with_url(url) - if url =~ /.zip$/ + path = URI.parse(url).path + if path =~ /.zip$/ :zip - elsif url =~ /.(tgz|tar\.gz)$/ + elsif path =~ /.(tgz|tar\.gz)$/ :tgz - elsif url =~ /.tar$/ + elsif path =~ /.tar$/ :tar - elsif url =~ /.(tbz|tar\.bz2)$/ + elsif path =~ /.(tbz|tar\.bz2)$/ :tbz - elsif url =~ /.(txz|tar\.xz)$/ + elsif path =~ /.(txz|tar\.xz)$/ :txz else nil diff --git a/spec/http_spec.rb b/spec/http_spec.rb index d2621de..9f1d36c 100644 --- a/spec/http_spec.rb +++ b/spec/http_spec.rb @@ -17,6 +17,12 @@ module Downloader tmp_folder('lib/file.txt').read.strip.should =~ /This is a fixture/ end + it 'ignores any params in the url' do + options = { :http => "#{@fixtures_url}/lib.zip?param=value" } + downloader = Downloader.for_target(tmp_folder, options) + downloader.send(:type).should == :zip + end + it 'should download file and unzip it when the target folder name contains quotes or spaces' do options = { :http => "#{@fixtures_url}/lib.zip" } downloader = Downloader.for_target(tmp_folder_with_quotes, options) @@ -103,43 +109,43 @@ module Downloader #-------------------------------------------------------------------------# 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 @@ -147,25 +153,25 @@ module Downloader end 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