Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle unexpected source structure #119

Merged
merged 2 commits into from
May 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 7 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,13 @@ 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 version directory ' \
"`#{basename}` was encountered for the " \
"`#{pod_dir}` Pod 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