From bd3eb2e8c975be70d07dc583508bfcb69f4e58d7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 24 May 2024 15:50:20 +0100 Subject: [PATCH] sync/shared-config: tweak rubocop. - Use different source file from Homebrew/brew. - Reject lines that don't make sense. --- .github/actions/sync/shared-config.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/actions/sync/shared-config.rb b/.github/actions/sync/shared-config.rb index 707b6ae6..2696f5b5 100755 --- a/.github/actions/sync/shared-config.rb +++ b/.github/actions/sync/shared-config.rb @@ -5,6 +5,7 @@ require "fileutils" require "open3" require "pathname" +require "yaml" # This makes sense for a standalone script. # rubocop:disable Style/TopLevelMethodDefinition @@ -24,10 +25,19 @@ def git(*args) ruby_version = ".ruby-version" rubocop_yml = ".rubocop.yml" +rejected_rubocop_lines_regex = // homebrew_ruby_version = - (homebrew_repository_path/"Library/Homebrew/vendor/portable-ruby-version").read.chomp.sub(/_\d+$/, "") -homebrew_rubocop_config = homebrew_repository_path/"Library/Homebrew/#{rubocop_yml}" + (homebrew_repository_path/"Library/Homebrew/vendor/portable-ruby-version").read + .chomp + .sub(/_\d+$/, "") +homebrew_rubocop_config_yaml = YAML.load_file( + homebrew_repository_path/"Library/#{rubocop_yml}", + permitted_classes: [Symbol, Regexp], +) +homebrew_rubocop_config = homebrew_rubocop_config_yaml.reject do |key, _| + key.match?(%r{\Arequire|inherit_from|inherit_mode|Cask/|Formula|Homebrew/|Performance/|RSpec|Sorbet/}) +end.to_yaml puts "Detecting changes…" [ @@ -43,7 +53,7 @@ def git(*args) when ruby_version target_path.write("#{homebrew_ruby_version}\n") when rubocop_yml - FileUtils.cp homebrew_rubocop_config, target_path + target_path.write("#{homebrew_rubocop_config}\n") else FileUtils.cp file, target_path end