From 46d758d5cf792e7f591bec395faf4fe9aeb937d3 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 21 Mar 2024 22:06:26 -0700 Subject: [PATCH] Port Homebrew::DevCmd::UpdateLicenseData --- .../Homebrew/dev-cmd/update-license-data.rb | 45 ++++++++++--------- .../test/dev-cmd/update-license-data_spec.rb | 3 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Library/Homebrew/dev-cmd/update-license-data.rb b/Library/Homebrew/dev-cmd/update-license-data.rb index 4bb5e89e8f..c68fe365e7 100644 --- a/Library/Homebrew/dev-cmd/update-license-data.rb +++ b/Library/Homebrew/dev-cmd/update-license-data.rb @@ -1,34 +1,35 @@ -# typed: true +# typed: strict # frozen_string_literal: true +require "abstract_command" require "cli/parser" require "utils/spdx" require "system_command" module Homebrew - extend SystemCommand::Mixin + module DevCmd + class UpdateLicenseData < AbstractCommand + include SystemCommand::Mixin - sig { returns(CLI::Parser) } - def self.update_license_data_args - Homebrew::CLI::Parser.new do - description <<~EOS - Update SPDX license data in the Homebrew repository. - EOS - named_args :none - end - end + cmd_args do + description <<~EOS + Update SPDX license data in the Homebrew repository. + EOS + named_args :none + end - def self.update_license_data - update_license_data_args.parse - - SPDX.download_latest_license_data! - diff = system_command "git", args: [ - "-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", SPDX::DATA_PATH - ] - if diff.status.success? - ofail "No changes to SPDX license data." - else - puts "SPDX license data updated." + sig { override.void } + def run + SPDX.download_latest_license_data! + diff = system_command "git", args: [ + "-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", SPDX::DATA_PATH + ] + if diff.status.success? + ofail "No changes to SPDX license data." + else + puts "SPDX license data updated." + end + end end end end diff --git a/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb b/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb index 0acb9110ce..e4505c604f 100644 --- a/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb +++ b/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true require "cmd/shared_examples/args_parse" +require "dev-cmd/update-license-data" -RSpec.describe "brew update-license-data" do +RSpec.describe Homebrew::DevCmd::UpdateLicenseData do it_behaves_like "parseable arguments" end