Commit d00517d5 authored by Francis Chong's avatar Francis Chong

Make sure pod removes the .git directory when cleaning (using github downloader)

parent 819d1eb0
...@@ -60,13 +60,21 @@ module Pod ...@@ -60,13 +60,21 @@ module Pod
end end
def clean def clean
# no-op if download_only?
FileUtils.rm_f(tmp_path)
else
super
end
end end
def tarball_url_for(id) def tarball_url_for(id)
original_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a) original_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a)
"https://github.com/#{username}/#{reponame}/tarball/#{id}" "https://github.com/#{username}/#{reponame}/tarball/#{id}"
end end
def tmp_path
target_path + "tarball.tar.gz"
end
private private
...@@ -75,8 +83,6 @@ module Pod ...@@ -75,8 +83,6 @@ module Pod
end end
def download_and_extract_tarball(id) def download_and_extract_tarball(id)
tmp_path = target_path + "tarball.tar.gz"
File.open(tmp_path, "w+") do |tmpfile| File.open(tmp_path, "w+") do |tmpfile|
open tarball_url_for(id) do |archive| open tarball_url_for(id) do |archive|
tmpfile.write Zlib::GzipReader.new(archive).read tmpfile.write Zlib::GzipReader.new(archive).read
...@@ -84,8 +90,6 @@ module Pod ...@@ -84,8 +90,6 @@ module Pod
system "tar xf #{tmpfile.path} -C #{target_path} --strip-components 1" system "tar xf #{tmpfile.path} -C #{target_path} --strip-components 1"
end end
FileUtils.rm_f(tmp_path)
end end
end end
end end
......
...@@ -84,9 +84,21 @@ describe "Pod::Downloader" do ...@@ -84,9 +84,21 @@ describe "Pod::Downloader" do
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
VCR.use_cassette('tarballs', :record => :new_episodes) { downloader.download } VCR.use_cassette('tarballs', :record => :new_episodes) { downloader.download }
downloader.clean
(@pod.root + 'tarball.tar.gz').should.not.exist (@pod.root + 'tarball.tar.gz').should.not.exist
end end
it "removes the .git directory when cleaning" do
@pod.specification.stubs(:source).returns(
:git => "git://github.com/lukeredpath/libPusher.git", :download_only => false
)
downloader = Pod::Downloader.for_pod(@pod)
downloader.download
downloader.clean
(@pod.root + '.git').should.not.exist
end
end end
describe "for Mercurial" do describe "for Mercurial" do
......
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