From 5fb593f1634d459dde1f8915ccbd5889f297bc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ga=C3=9F?= Date: Mon, 15 Jul 2024 11:59:36 +0200 Subject: [PATCH 1/4] fix "undefined method `=~' for false:FalseClass" on Ruby >= 3.2 see https://bugs.ruby-lang.org/issues/15231 --- lib/octocatalog-diff/catalog-diff/display/text.rb | 3 ++- spec/octocatalog-diff/tests/catalog-diff/display/text_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/octocatalog-diff/catalog-diff/display/text.rb b/lib/octocatalog-diff/catalog-diff/display/text.rb index 923f665b..6c522f02 100644 --- a/lib/octocatalog-diff/catalog-diff/display/text.rb +++ b/lib/octocatalog-diff/catalog-diff/display/text.rb @@ -367,12 +367,13 @@ def self.addition_only_no_truncation(depth, hash) # Single line strings hash.keys.sort.map do |key| - next if hash[key] =~ /\n/ + next if hash[key].kind_of?(String) && hash[key] =~ /\n/ result << left_pad(2 * depth + 4, [key.inspect, ': ', hash[key].inspect].join('')).green end # Multi-line strings hash.keys.sort.map do |key| + next if !hash[key].kind_of?(String) next if hash[key] !~ /\n/ result << left_pad(2 * depth + 4, [key.inspect, ': >>>'].join('')).green result.concat hash[key].split(/\n/).map(&:green) diff --git a/spec/octocatalog-diff/tests/catalog-diff/display/text_spec.rb b/spec/octocatalog-diff/tests/catalog-diff/display/text_spec.rb index f05f491c..9d9069d4 100644 --- a/spec/octocatalog-diff/tests/catalog-diff/display/text_spec.rb +++ b/spec/octocatalog-diff/tests/catalog-diff/display/text_spec.rb @@ -254,7 +254,8 @@ 'mode' => '0644', 'content' => 'x' * 150, 'owner' => 'root', - 'group' => 'wheel' + 'group' => 'wheel', + 'force' => true, } } ] From 45a7b7364d6fbd513af359ea4410b97ea4287ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ga=C3=9F?= Date: Mon, 15 Jul 2024 15:55:44 +0200 Subject: [PATCH 2/4] =?UTF-8?q?fix=20=E2=80=9Ctried=20to=20create=20Proc?= =?UTF-8?q?=20object=20without=20a=20block=E2=80=9D=20on=20Ruby=203.x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb b/lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb index 5e2747dd..cba3d4dc 100644 --- a/lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb +++ b/lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb @@ -66,12 +66,12 @@ def remove_compilation_dir(v, dir) value end - def traverse(a) + def traverse(a, &p) case a when Array - a.map { |v| traverse(v, &Proc.new) } + a.map { |v| traverse(v, &p) } when Hash - traverse(a.values, &Proc.new) + traverse(a.values, &p) else yield a end From c6d2c2553ae10a4521992416ddb54e8aca93bc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ga=C3=9F?= Date: Mon, 15 Jul 2024 16:02:26 +0200 Subject: [PATCH 3/4] fix "undefined method `=~'" for Array on Ruby >= 3.2 --- lib/octocatalog-diff/catalog-diff/differ.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/octocatalog-diff/catalog-diff/differ.rb b/lib/octocatalog-diff/catalog-diff/differ.rb index 3d959fa0..997c8a71 100644 --- a/lib/octocatalog-diff/catalog-diff/differ.rb +++ b/lib/octocatalog-diff/catalog-diff/differ.rb @@ -412,7 +412,7 @@ def ignore_match?(rule_in, diff_type, hsh, old_val, new_val) end # Special 'attributes': Ignore specific diff types (+ add, - remove, ~ and ! change) - if rule[:attr] =~ /\A[\-\+~!]+\Z/ + if rule[:attr].is_a?(String) && rule[:attr] =~ /\A[\-\+~!]+\Z/ return ignore_match_true(hsh, rule) if rule[:attr].include?(diff_type) return false end From a9374d6c8a1663ae67a1cd4b43db777fd2b89e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ga=C3=9F?= Date: Mon, 15 Jul 2024 16:03:09 +0200 Subject: [PATCH 4/4] fix Psych::DisallowedClass on Ruby >= 3.1 --- lib/octocatalog-diff/facts/yaml.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/octocatalog-diff/facts/yaml.rb b/lib/octocatalog-diff/facts/yaml.rb index 35c03342..9879221b 100644 --- a/lib/octocatalog-diff/facts/yaml.rb +++ b/lib/octocatalog-diff/facts/yaml.rb @@ -22,7 +22,7 @@ def self.fact_retriever(options = {}, node = '') fact_file_data[0] = '---' if fact_file_data[0] =~ /^---/ # Load the parsed fact file. - parsed = YAML.load(fact_file_data.join("\n")) + parsed = YAML.load(fact_file_data.join("\n"), permitted_classes: [Time]) # This is a handler for a YAML file that has just the facts and none of the # structure. For example if you saved the output of `facter -y` to a file and