Commit 20ea9926 authored by Danielle Tomlinson's avatar Danielle Tomlinson Committed by GitHub

Merge pull request #5809 from maschall/5807-specify-sources-for-update

[update] adding --sources to specify to only update pods from a repo
parents 662af9bf b58f6644
......@@ -8,7 +8,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements
* None.
* [update] adding --sources to specify to only update pods from a repo
[Mark Schall](https://github.com/maschall)
[#5809](https://github.com/CocoaPods/CocoaPods/pull/5809)
##### Bug Fixes
......
......@@ -19,8 +19,29 @@ module Pod
CLAide::Argument.new('POD_NAMES', false, true),
]
def self.options
[
['--sources=https://github.com/artsy/Specs', 'The sources from which to only update dependent pods ' \
'Multiple sources must be comma-delimited.'],
].concat(super)
end
def initialize(argv)
@pods = argv.arguments! unless argv.arguments.empty?
source_urls = argv.option('sources', '').split(',')
unless source_urls.empty?
source_pods = source_urls.flat_map { |url| config.sources_manager.source_with_name_or_url(url).pods }
unless source_pods.empty?
source_pods = source_pods.select { |pod| config.lockfile.pod_names.include?(pod) }
if @pods
@pods += source_pods
else
@pods = source_pods unless source_pods.empty?
end
end
end
super
end
......
......@@ -18,6 +18,21 @@ module Pod
end
end
def generate_lockfile
podfile = Podfile.new do
platform :ios
pod 'BananaLib', '1.0'
end
specs = [
Specification.new do |s|
s.name = 'BananaLib'
s.version = '1.0'
end,
]
external_sources = {}
Lockfile.generate(podfile, specs, external_sources).write_to_disk(temporary_directory + 'Podfile.lock')
end
describe 'updates of the spec repos' do
before do
Installer.any_instance.expects(:install!)
......@@ -34,6 +49,49 @@ module Pod
end
end
describe 'installs the updates' do
before do
Installer.any_instance.expects(:install!)
end
describe 'all pods' do
it 'updates all pods' do
Installer.any_instance.expects(:update=).with(true)
run_command('update')
end
end
describe 'selected pods' do
before do
generate_lockfile
end
it 'updates selected pods' do
Installer.any_instance.expects(:update=).with(:pods => ['BananaLib'])
run_command('update', 'BananaLib')
end
end
describe 'selected repo' do
before do
generate_lockfile
set_up_test_repo
config.repos_dir = SpecHelper.tmp_repos_path
spec1 = (fixture('spec-repos') + 'test_repo/JSONKit/1.4/JSONKit.podspec').read
spec2 = (fixture('spec-repos') + 'test_repo/BananaLib/1.0/BananaLib.podspec').read
File.open(temporary_directory + 'JSONKit.podspec', 'w') { |f| f.write(spec1) }
File.open(temporary_directory + 'BananaLib.podspec', 'w') { |f| f.write(spec2) }
end
it 'updates pods in repo and in lockfile' do
Installer.any_instance.expects(:update=).with(:pods => ['BananaLib'])
run_command('update', '--sources=master')
end
end
end
it 'tells the user that no Lockfile was found in the project dir' do
exception = lambda { run_command('update', 'BananaLib', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the project directory"
......@@ -41,18 +99,7 @@ module Pod
describe 'tells the user that the Pods cannot be updated unless they are installed' do
before do
podfile = Podfile.new do
platform :ios
pod 'BananaLib', '1.0'
end
specs = [
Specification.new do |s|
s.name = 'BananaLib'
s.version = '1.0'
end,
]
external_sources = {}
Lockfile.generate(podfile, specs, external_sources).write_to_disk(temporary_directory + 'Podfile.lock')
generate_lockfile
end
it 'for a single missing Pod' 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