Commit 7395fa95 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7028 from amorde/cocoapods-6979

Fix common paths sometimes calculating incorrectly
parents 6d6d6bb3 f3650d11
......@@ -30,6 +30,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
* Fix common paths sometimes calculating incorrectly
[amorde](https://github.com/amorde)
[#7028](https://github.com/CocoaPods/CocoaPods/pull/7028)
* Do not code sign OSX targets for testing bundles
[Justin Martin](https://github.com/justinseanmartin)
[#7027](https://github.com/CocoaPods/CocoaPods/pull/7027)
......
......@@ -242,7 +242,7 @@ module Pod
end
# Returns a Pathname of the nearest parent from which all the given paths descend.
# Converts each Pathname to a string and finds the longest common prefix
# Converts each Pathname to a list of path components and finds the longest common prefix
#
# @param [Array<Pathname>] paths
# The paths to files or directories on disk. Must be absolute paths
......@@ -258,10 +258,12 @@ module Pod
path.dirname.to_s
end
min, max = strs.minmax
min = min.split('/')
max = max.split('/')
idx = min.size.times { |i| break i if min[i] != max[i] }
result = Pathname.new(min[0...idx])
result = Pathname.new(min[0...idx].join('/'))
# Don't consider "/" a common path
return result unless result.to_s == '/'
return result unless result.to_s == '' || result.to_s == '/'
end
# Computes the destination sub-directory in the sandbox
......
......@@ -252,6 +252,18 @@ module Pod
result.should == Pathname.new('/Base/Sub/A')
end
it 'compares path components instead of string prefixes' do
paths = [
'/Base/Sub/A/1.txt',
'/Base/Sub/AA/2.txt',
'/Base/Sub/AAA/B/1.txt',
'/Base/Sub/AAAA/B/2.txt',
'/Base/Sub/AAAAA/D/E/1.txt',
].map { |p| Pathname.new(p) }
result = @installer.send(:common_path, paths)
result.should == Pathname.new('/Base/Sub')
end
it 'should not consider root \'/\' a common path' do
paths = [
'/A/B/C',
......
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