Commit ea85925b authored by Oleksandr Kruk's avatar Oleksandr Kruk

Add --exclude-pods option for pod update command

Allows to skip the update operation for specific pods
E.g.: pod update --exclude-pods=Alamofire will update all
installed pods from the lockfile except Alamofire
parent 4739ff19
......@@ -8,6 +8,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### 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
[Muhammed Yavuz Nuzumlalı](https://github.com/manuyavuz)
[#7473](https://github.com/CocoaPods/CocoaPods/pull/7473)
......
......@@ -23,6 +23,7 @@ module Pod
[
['--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.'],
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited.'],
].concat(super)
end
......@@ -30,6 +31,7 @@ module Pod
@pods = argv.arguments! unless argv.arguments.empty?
source_urls = argv.option('sources', '').split(',')
excluded_pods = argv.option('exclude-pods', '').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?
......@@ -42,6 +44,20 @@ module Pod
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
end
......
......@@ -15,6 +15,8 @@ module Pod
File.open(file, 'w') do |f|
f.puts('platform :ios')
f.puts('pod "BananaLib", "1.0"')
f.puts('pod "CoconutLib", "1.0"')
f.puts('pod "OCMock", "3.4"')
end
end
......@@ -22,12 +24,22 @@ module Pod
podfile = Podfile.new do
platform :ios
pod 'BananaLib', '1.0'
pod 'CoconutLib', '1.0'
pod 'OCMock', '3.4'
end
specs = [
Specification.new do |s|
s.name = 'BananaLib'
s.version = '1.0'
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 = {}
specs_by_source = {
......@@ -90,7 +102,7 @@ module Pod
end
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')
end
end
......@@ -118,6 +130,45 @@ module Pod
exception.message.should.include 'Pods `Reachability`, `BananaLib2` are not installed and cannot be updated'
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
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