Commit 4e6b852f authored by Ben Asher's avatar Ben Asher Committed by GitHub

Merge pull request #6553 from adellibovi/add-exit-code-no-spec-found

Return different exit status (31) when spec not found
parents d2f30d88 a1d13773
......@@ -24,6 +24,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Alfredo Delli Bovi](https://github.com/adellibovi)
[#6525](https://github.com/CocoaPods/CocoaPods/issues/6525)
* Return new exit code (31) when spec not found
[Alfredo Delli Bovi](https://github.com/adellibovi)
[#6033](https://github.com/CocoaPods/CocoaPods/issues/6033)
## 1.2.1.beta.1 (2017-03-08)
......
......@@ -21,6 +21,10 @@ module Pod
This will configure the project to reference the Pods static library,
add a build configuration file, and add a post build script to copy
Pod resources.
This may return one of several error codes if it encounters problems.
* `1` Generic error code
* `31` Spec not found (i.e out-of-date source repos, mistyped Pod name etc...)
DESC
def self.options
......
......@@ -2,6 +2,12 @@ require 'molinillo'
require 'cocoapods/resolver/lazy_specification'
module Pod
class NoSpecFoundError < Informative
def exit_status
@exit_status ||= 31
end
end
# The resolver is responsible of generating a list of specifications grouped
# by target for a given Podfile.
#
......@@ -389,6 +395,7 @@ module Pod
#
def handle_resolver_error(error)
message = error.message.dup
type = Informative
case error
when Molinillo::VersionConflict
error.conflicts.each do |name, conflict|
......@@ -427,6 +434,7 @@ module Pod
found_conflicted_specs = conflicts.reject { |c| search_for(c).empty? }
if found_conflicted_specs.empty?
# There are no existing specification inside any of the spec repos with given requirements.
type = NoSpecFoundError
dependencies = conflicts.count == 1 ? 'dependency' : 'dependencies'
message << "\n\nNone of your spec sources contain a spec satisfying "\
"the #{dependencies}: `#{conflicts.join(', ')}`." \
......@@ -443,7 +451,7 @@ module Pod
end
end
end
raise Informative, message
raise type, message
end
# Returns whether the given spec is platform-compatible with the dependency
......
......@@ -373,7 +373,7 @@ module Pod
pod 'AFNetworking', '999.999.999'
end
resolver = Resolver.new(config.sandbox, podfile, empty_graph, config.sources_manager.all)
e = lambda { resolver.resolve }.should.raise Informative
e = lambda { resolver.resolve }.should.raise NoSpecFoundError
e.message.should.match(/Unable to satisfy the following requirements/)
e.message.should.match(/`AFNetworking \(= 999\.999\.999\)` required by `Podfile`/)
e.message.should.match(/None of your spec sources contain a spec satisfying the dependency: `AFNetworking \(= 999\.999\.999\)`./)
......@@ -382,6 +382,7 @@ module Pod
e.message.should.match(/ * not added the source repo that hosts the Podspec to your Podfile./)
e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update`/)
e.message.should.match(/Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default./)
e.exit_status.should.equal(31)
end
it 'raises with a list of dependencies if there are many dependencies but no versions of a dependency exists' do
......@@ -392,7 +393,7 @@ module Pod
locked_deps = dependency_graph_from_array([Dependency.new('AFNetworking', '= 1.4')])
resolver = Resolver.new(config.sandbox, podfile, locked_deps, config.sources_manager.all)
e = lambda { resolver.resolve }.should.raise Informative
e = lambda { resolver.resolve }.should.raise NoSpecFoundError
e.message.should.match(/Unable to satisfy the following requirements/)
e.message.should.match(/`AFNetworking \(= 3.0.1\)` required by `Podfile`/)
e.message.should.match(/`AFNetworking \(= 1.4\)` required by `Podfile.lock`/)
......@@ -403,6 +404,7 @@ module Pod
e.message.should.match(/ * not added the source repo that hosts the Podspec to your Podfile./)
e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update`/)
e.message.should.match(/Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default./)
e.exit_status.should.equal(31)
end
it 'takes into account locked dependencies' do
......
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