Port Homebrew::DevCmd::UpdateLicenseData

This commit is contained in:
Douglas Eichelberger 2024-03-21 22:06:26 -07:00
parent bdf8fbc1ad
commit 46d758d5cf
2 changed files with 25 additions and 23 deletions

View File

@ -1,34 +1,35 @@
# typed: true # typed: strict
# frozen_string_literal: true # frozen_string_literal: true
require "abstract_command"
require "cli/parser" require "cli/parser"
require "utils/spdx" require "utils/spdx"
require "system_command" require "system_command"
module Homebrew module Homebrew
extend SystemCommand::Mixin module DevCmd
class UpdateLicenseData < AbstractCommand
include SystemCommand::Mixin
sig { returns(CLI::Parser) } cmd_args do
def self.update_license_data_args description <<~EOS
Homebrew::CLI::Parser.new do Update SPDX license data in the Homebrew repository.
description <<~EOS EOS
Update SPDX license data in the Homebrew repository. named_args :none
EOS end
named_args :none
end
end
def self.update_license_data sig { override.void }
update_license_data_args.parse def run
SPDX.download_latest_license_data!
SPDX.download_latest_license_data! diff = system_command "git", args: [
diff = system_command "git", args: [ "-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", SPDX::DATA_PATH
"-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", SPDX::DATA_PATH ]
] if diff.status.success?
if diff.status.success? ofail "No changes to SPDX license data."
ofail "No changes to SPDX license data." else
else puts "SPDX license data updated."
puts "SPDX license data updated." end
end
end end
end end
end end

View File

@ -1,7 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
require "cmd/shared_examples/args_parse" 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" it_behaves_like "parseable arguments"
end end