Commit 08a054a1 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Validator] Allow specifying repo names to `pod {spec,lib} lint --sources`.

Closes https://github.com/CocoaPods/CocoaPods/issues/2685.
parent b7ba888d
......@@ -52,6 +52,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins)
[#2992](https://github.com/CocoaPods/CocoaPods/issues/2992)
* Allow specifying repo names to `pod {spec,lib} lint --sources`.
[Samuel Giddins](https://github.com/segiddins)
[#2685](https://github.com/CocoaPods/CocoaPods/issues/2685)
##### Bug Fixes
* Added support for .tpp C++ header files in specs (previously were getting
......
......@@ -114,7 +114,7 @@ module Pod
['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--use-frameworks', 'Lint uses frameworks to install the spec'],
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
['--sources=https://github.com/artsy/Specs,master', 'The sources from which to pull dependant pods ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super)
end
......
......@@ -21,7 +21,7 @@ module Pod
['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--use-frameworks', 'Lint uses frameworks to install the spec'],
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
['--sources=https://github.com/artsy/Specs,master', 'The sources from which to pull dependant pods ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super)
end
......@@ -34,7 +34,7 @@ module Pod
@only_subspec = argv.option('subspec')
@use_frameworks = argv.flag?('use-frameworks')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments!
@podspecs_paths = argv.arguments!
super
end
......
......@@ -57,6 +57,20 @@ module Pod
source
end
# Returns the source whose {Source#name} or {Source#url} is equal to the
# given `name_or_url`.
#
# @return [Source] The source whose {Source#name} or {Source#url} is equal to the
# given `name_or_url`.
#
# @param [String] name_or_url
# The name or the URL of the source.
#
def source_with_name_or_url(name_or_url)
all.find { |s| s.name == name_or_url } ||
find_or_create_source_with_url(name_or_url)
end
# @return [Array<Source>] The list of all the sources known to this
# installation of CocoaPods.
#
......
......@@ -23,7 +23,7 @@ module Pod
# the Source URLs to use in creating a {Podfile}.
#
def initialize(spec_or_path, source_urls)
@source_urls = source_urls
@source_urls = source_urls.map { |url| SourcesManager.source_with_name_or_url(url) }.map(&:url)
@linter = Specification::Linter.new(spec_or_path)
end
......
......@@ -211,6 +211,21 @@ module Pod
e.should.not.raise
end
end
describe 'finding or creating a source by name or URL' do
it 'returns an existing source with a matching name' do
SourcesManager.expects(:name_for_url).never
SourcesManager.source_with_name_or_url('test_repo').name.
should == 'test_repo'
end
it 'tries by url when there is no matching name' do
Command::Repo::Add.any_instance.stubs(:run).once
SourcesManager.stubs(:source_with_url).returns(nil).then.returns('Source')
SourcesManager.source_with_name_or_url('https://github.com/artsy/Specs.git').
should == 'Source'
end
end
end
end
......
......@@ -329,11 +329,12 @@ module Pod
end
it 'repects the source_urls parameter' do
sources = %w(https://github.com/CocoaPods/Specs.git https://github.com/artsy/Specs.git)
sources = %w(master https://github.com/CocoaPods/Specs.git)
Command::Repo::Add.any_instance.stubs(:run)
validator = Validator.new(podspec_path, sources)
validator.stubs(:validate_url)
podfile = validator.send(:podfile_from_spec, :ios, '5.0')
podfile.sources.should == sources
podfile.sources.should == %w(https://github.com/CocoaPods/Specs.git)
end
it 'uses xcodebuild to generate warnings' 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