brew/Library/Homebrew/dev-cmd/update-license-data.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

2020-11-25 17:03:23 +01:00
# typed: true
# frozen_string_literal: true
require "cli/parser"
2020-08-04 10:07:57 -07:00
require "utils/spdx"
require "system_command"
module Homebrew
2020-10-20 12:03:48 +02:00
extend T::Sig
include SystemCommand::Mixin
2020-10-20 12:03:48 +02:00
module_function
2020-10-20 12:03:48 +02:00
sig { returns(CLI::Parser) }
2020-06-25 05:46:18 +08:00
def update_license_data_args
Homebrew::CLI::Parser.new do
description <<~EOS
Update SPDX license data in the Homebrew repository.
2020-06-25 05:10:29 +08:00
EOS
switch "--fail-if-not-changed",
hidden: true,
description: "Return a failing status code if current license data's version is the same as " \
"the upstream. This can be used to notify CI when the SPDX license data is out of date."
2020-11-12 10:40:41 -05:00
2021-01-10 14:26:40 -05:00
named_args :none
end
2020-06-25 05:46:18 +08:00
end
2020-06-25 05:46:18 +08:00
def update_license_data
2020-07-30 18:40:10 +02:00
args = update_license_data_args.parse
odeprecated "brew update-license-data --fail-if-not-changed" if args.fail_if_not_changed?
2020-08-04 10:07:57 -07:00
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
2020-06-25 05:46:18 +08:00
end