diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-12-07 14:27:20 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-12-07 14:27:20 -0800 |
commit | 030266db26be2f307e554c48244283ada7c9e364 (patch) | |
tree | 1488804d66a85e768e45a72d04897637263f5da0 /lib/chef/node_map.rb | |
parent | fa1b53f2638bdf71ec7fe7c270b289b7239e17c0 (diff) | |
download | chef-030266db26be2f307e554c48244283ada7c9e364.tar.gz |
fix alphabetic sorting of classeslcg/node-map-speedup
but we really shouldn't do this...
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/node_map.rb')
-rw-r--r-- | lib/chef/node_map.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index f650e56c46..0d7d986653 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -221,21 +221,19 @@ class Chef if cmp == 0 # Sort by class name (ascending) as well, if all other properties # are exactly equal + # XXX: remove this in Chef-14 and use last-writer-wins (prepend if they match) if new_matcher[:value].is_a?(Class) && !new_matcher[:override] - cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name } + cmp = compare_matcher_properties(new_matcher[:value].name, matcher[:value].name) end end cmp end def compare_matcher_properties(a, b) - # We treat false / true and nil / not-nil with the same comparison - a = nil if a == false - b = nil if b == false - - return 1 if a.nil? && !b.nil? - return -1 if b.nil? && !a.nil? - return 0 if a.nil? && b.nil? + # falsity comparisons here handle both "nil" and "false" + return 1 if !a && b + return -1 if !b && a + return 0 if !a && !b # Check for blacklists ('!windows'). Those always come *after* positive # whitelists. |