summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOle Claussen <claussen.ole@gmail.com>2017-05-22 14:43:02 +0200
committerOle Claussen <claussen.ole@gmail.com>2017-05-29 10:51:32 +0200
commit922c9f931396d16da6984bd31f767ade6495355e (patch)
tree133c4f0ec67528e4179c5a46077e3bf260d782ca /lib
parent6b9ebb11c68d2a03a78644ffc2134941c46a15ed (diff)
downloadchef-922c9f931396d16da6984bd31f767ade6495355e.tar.gz
Generate a valid Gemfile, even multiple gem declaration with keyword arguments exist.
Previously, keyword argemunts to the gem declarations would just be appended, resulting in invalid Gemfiles. Now, keyword arguments are merged together. In case of conflict, the last declaration will win. Signed-off-by: Ole Claussen <claussen.ole@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/cookbook/gem_installer.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/chef/cookbook/gem_installer.rb b/lib/chef/cookbook/gem_installer.rb
index 5b1426e4e8..71e513a86b 100644
--- a/lib/chef/cookbook/gem_installer.rb
+++ b/lib/chef/cookbook/gem_installer.rb
@@ -40,6 +40,13 @@ class Chef
cookbook_collection.each do |cookbook_name, cookbook_version|
cookbook_version.metadata.gems.each do |args|
+ if cookbook_gems[args.first].last.is_a?(Hash)
+ args << {} unless args.last.is_a?(Hash)
+ args.last.merge!(cookbook_gems[args.first].pop) do |key, v1, v2|
+ Chef::Log.warn "Conflicting requirements for gem '#{args.first}', will use #{key.inspect} => #{v2.inspect}" if v1 != v2
+ v2
+ end
+ end
cookbook_gems[args.first] += args[1..-1]
end
end