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