Unverified Commit 3db51207 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7524 from 0mega/allow-skipping-pod-update

Allows to skip update operation for specific pods
parents bf310672 ea85925b
...@@ -8,6 +8,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -8,6 +8,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements ##### Enhancements
* Add `--exclude-pods` option to `pod update` to allow excluding specific pods from update
[Oleksandr Kruk](https://github.com/0mega)
[#7334](https://github.com/CocoaPods/CocoaPods/issues/7334)
* Improve `pod install` performance for pods with exact file paths rather than glob patterns * Improve `pod install` performance for pods with exact file paths rather than glob patterns
[Muhammed Yavuz Nuzumlalı](https://github.com/manuyavuz) [Muhammed Yavuz Nuzumlalı](https://github.com/manuyavuz)
[#7473](https://github.com/CocoaPods/CocoaPods/pull/7473) [#7473](https://github.com/CocoaPods/CocoaPods/pull/7473)
......
...@@ -23,6 +23,7 @@ module Pod ...@@ -23,6 +23,7 @@ module Pod
[ [
['--sources=https://github.com/artsy/Specs,master', 'The sources from which to update dependent pods. ' \ ['--sources=https://github.com/artsy/Specs,master', 'The sources from which to update dependent pods. ' \
'Multiple sources must be comma-delimited. The master repo will not be included by default with this option.'], 'Multiple sources must be comma-delimited. The master repo will not be included by default with this option.'],
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited.'],
].concat(super) ].concat(super)
end end
...@@ -30,6 +31,7 @@ module Pod ...@@ -30,6 +31,7 @@ module Pod
@pods = argv.arguments! unless argv.arguments.empty? @pods = argv.arguments! unless argv.arguments.empty?
source_urls = argv.option('sources', '').split(',') source_urls = argv.option('sources', '').split(',')
excluded_pods = argv.option('exclude-pods', '').split(',')
unless source_urls.empty? unless source_urls.empty?
source_pods = source_urls.flat_map { |url| config.sources_manager.source_with_name_or_url(url).pods } source_pods = source_urls.flat_map { |url| config.sources_manager.source_with_name_or_url(url).pods }
unless source_pods.empty? unless source_pods.empty?
...@@ -42,6 +44,20 @@ module Pod ...@@ -42,6 +44,20 @@ module Pod
end end
end end
unless excluded_pods.empty?
@pods ||= config.lockfile.pod_names.dup
non_installed_pods = (excluded_pods - @pods)
unless non_installed_pods.empty?
pluralized_words = non_installed_pods.length > 1 ? %w(Pods are) : %w(Pod is)
message = "Trying to skip `#{non_installed_pods.join('`, `')}` #{pluralized_words.first} " \
"which #{pluralized_words.last} not installed"
raise Informative, message
end
@pods.delete_if { |pod| excluded_pods.include?(pod) }
end
super super
end end
......
...@@ -15,6 +15,8 @@ module Pod ...@@ -15,6 +15,8 @@ module Pod
File.open(file, 'w') do |f| File.open(file, 'w') do |f|
f.puts('platform :ios') f.puts('platform :ios')
f.puts('pod "BananaLib", "1.0"') f.puts('pod "BananaLib", "1.0"')
f.puts('pod "CoconutLib", "1.0"')
f.puts('pod "OCMock", "3.4"')
end end
end end
...@@ -22,12 +24,22 @@ module Pod ...@@ -22,12 +24,22 @@ module Pod
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
pod 'BananaLib', '1.0' pod 'BananaLib', '1.0'
pod 'CoconutLib', '1.0'
pod 'OCMock', '3.4'
end end
specs = [ specs = [
Specification.new do |s| Specification.new do |s|
s.name = 'BananaLib' s.name = 'BananaLib'
s.version = '1.0' s.version = '1.0'
end, end,
Specification.new do |s|
s.name = 'CoconutLib'
s.version = '2.0'
end,
Specification.new do |s|
s.name = 'OCMock'
s.version = '3.4'
end,
] ]
external_sources = {} external_sources = {}
specs_by_source = { specs_by_source = {
...@@ -90,7 +102,7 @@ module Pod ...@@ -90,7 +102,7 @@ module Pod
end end
it 'updates pods in repo and in lockfile' do it 'updates pods in repo and in lockfile' do
Installer.any_instance.expects(:update=).with(:pods => ['BananaLib']) Installer.any_instance.expects(:update=).with(:pods => %w(BananaLib CoconutLib OCMock))
run_command('update', '--sources=master') run_command('update', '--sources=master')
end end
end end
...@@ -118,6 +130,45 @@ module Pod ...@@ -118,6 +130,45 @@ module Pod
exception.message.should.include 'Pods `Reachability`, `BananaLib2` are not installed and cannot be updated' exception.message.should.include 'Pods `Reachability`, `BananaLib2` are not installed and cannot be updated'
end end
end end
describe 'ignored pods' do
before do
generate_lockfile
end
describe 'successfully ignores skipped pods' do
before do
Installer.any_instance.expects(:install!)
end
it 'ignores skiped pod' do
Installer.any_instance.expects(:update=).with(:pods => %w(BananaLib CoconutLib))
run_command('update', '--exclude-pods=OCMock')
end
it 'ignores multiple skipped pods' do
Installer.any_instance.expects(:update=).with(:pods => ['OCMock'])
run_command('update', '--exclude-pods=BananaLib,CoconutLib')
end
end
describe 'when a single supplied Pod is not installed' do
it 'raises with single message' do
should.raise Informative do
run_command('update', '--exclude-pods=Reachability,BananaLib')
end.message.should.include 'Trying to skip `Reachability` Pod which is not installed'
end
end
describe 'when multiple supplied Pods are not installed' do
it 'raises with plural message' do
should.raise Informative do
run_command('update', '--exclude-pods=Reachability,Alamofire')
end.message.should.include 'Trying to skip `Reachability`, `Alamofire` ' \
'Pods which are not installed'
end
end
end
end end
end end
end end
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