Skip to content

Commit

Permalink
Gracefully handle unexpected source structure
Browse files Browse the repository at this point in the history
Closes #110
  • Loading branch information
segiddins committed Apr 25, 2014
1 parent d17af6d commit 7acf638
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
[#115](https://github.com/CocoaPods/Core/issues/115)
[#116](https://github.com/CocoaPods/Core/pull/116)

* Gracefully handle unexpected source structure
[Samuel E. Giddins](https://github.com/segiddins)
[#110](https://github.com/CocoaPods/Core/issues/110)

## 0.32.1
## 0.32.0

Expand Down
7 changes: 6 additions & 1 deletion lib/cocoapods-core/source/file_system_data_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ def versions(name)
return unless pod_dir.exist?
pod_dir.children.map do |v|
basename = v.basename.to_s
Version.new(basename) if v.directory? && basename[0, 1] != '.'
begin
Version.new(basename) if v.directory? && basename[0, 1] != '.'
rescue ArgumentError => e
raise Informative, "An unexpected directory (#{basename}) " \
"was encountered in the #{name} repository"
end
end.compact.sort.reverse.map(&:to_s)
end

Expand Down
8 changes: 8 additions & 0 deletions spec/source/file_system_data_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ module Pod
@subject.versions(nil)
end.message.should.match /No name/
end

it 'raises if a non-version-name directory is encountered' do
Pathname.any_instance.stubs(:children).returns([Pathname.new("/Hello")])
Pathname.any_instance.stubs(:directory?).returns(true)
e = lambda { @subject.versions('JSONKit') }.should.raise Informative
e.message.should.match /Hello/
e.message.should.not.match /Malformed version number string/
end
end

#-------------------------------------------------------------------------#
Expand Down

0 comments on commit 7acf638

Please sign in to comment.