Skip to content

Commit

Permalink
[LocalPod] Fixed clean paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Oct 4, 2012
1 parent 4b34972 commit 8e72cbe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)

Expand Down
8 changes: 5 additions & 3 deletions lib/cocoapods/local_pod.rb
Expand Up @@ -163,12 +163,14 @@ def clean!
#
# @return [Array<Strings>] 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
Expand Down
9 changes: 5 additions & 4 deletions spec/unit/local_pod_spec.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8e72cbe

Please sign in to comment.