From 8e72cbe16464bb31254bbb8a2bea3dff086bcded Mon Sep 17 00:00:00 2001 From: Fabio Pelosin Date: Thu, 4 Oct 2012 16:27:43 +0200 Subject: [PATCH] [LocalPod] Fixed clean paths. Closes #519 Closes #568 --- CHANGELOG.md | 4 ++++ lib/cocoapods/local_pod.rb | 8 +++++--- spec/unit/local_pod_spec.rb | 9 +++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92a576a457..5f8c0eb610 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.15.0...master) ###### Bug fixes + +- Fixed an issue that lead to empty directories for Pods. + [#519](https://github.com/CocoaPods/CocoaPods/issues/519) + [#568](https://github.com/CocoaPods/CocoaPods/issues/568) - Fixed a crash related to the RubyGems version informative. [#570](https://github.com/CocoaPods/CocoaPods/issues/570) diff --git a/lib/cocoapods/local_pod.rb b/lib/cocoapods/local_pod.rb index 446f78bb9b..a38069fabf 100644 --- a/lib/cocoapods/local_pod.rb +++ b/lib/cocoapods/local_pod.rb @@ -163,12 +163,14 @@ def clean! # # @return [Array] The paths that can be deleted. # + # @note The Paths are downcased to prevent issues. See #568. + # def clean_paths - cached_used_paths = used_files - files = Dir.glob(root + "**/*", File::FNM_DOTMATCH) + used = used_files.map(&:downcase) + files = Dir.glob(root + "**/*", File::FNM_DOTMATCH).map(&:downcase) files.reject! do |candidate| - candidate.end_with?('.', '..') || cached_used_paths.any? do |path| + candidate.end_with?('.', '..') || used.any? do |path| path.include?(candidate) || candidate.include?(path) end end diff --git a/spec/unit/local_pod_spec.rb b/spec/unit/local_pod_spec.rb index f9c0f081b1..471ba8aaea 100644 --- a/spec/unit/local_pod_spec.rb +++ b/spec/unit/local_pod_spec.rb @@ -56,11 +56,11 @@ end it "returns an expanded list the files to clean" do - clean_paths = @pod.clean_paths.map { |p| p.to_s.gsub(/.*Pods\/BananaLib/,'') } + clean_paths = @pod.clean_paths.map { |p| p.to_s.gsub(/.*pods\/bananalib/,'') } clean_paths.should.include "/.git/config" # * There are some hidden files on Travis # * The submodule of the repo (libPusher) can be ignore, to reduce noise of this test - clean_files_without_hidden = clean_paths.reject { |p| p.to_s.include?('/.') || p.to_s.include?('libPusher') } + clean_files_without_hidden = clean_paths.reject { |p| p.to_s.include?('/.') || p.to_s.include?('libpusher') } clean_files_without_hidden.should == %W[ /sub-dir /sub-dir/sub-dir-2 /sub-dir/sub-dir-2/somefile.txt ] end @@ -208,8 +208,9 @@ def assert_array_equals(expected, computed) /StoreKit/StoreKit_Prefix.pch /UIKit/UIKit_Prefix.pch ] - computed = @pod.clean_paths.each{ |p| p.gsub!(@pod.root.to_s, '') } - assert_array_equals(expected, computed) + root = @pod.root.to_s.downcase + computed = @pod.clean_paths.each{ |p| p.gsub!(root, '') } + assert_array_equals(expected.map(&:downcase), computed) end it "resolves the used files" do