From 922c9f931396d16da6984bd31f767ade6495355e Mon Sep 17 00:00:00 2001 From: Ole Claussen Date: Mon, 22 May 2017 14:43:02 +0200 Subject: 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 --- lib/chef/cookbook/gem_installer.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') 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 -- cgit v1.2.1