2020-11-25 17:03:23 +01:00
|
|
|
# typed: true
|
2020-06-23 01:39:10 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "cli/parser"
|
2020-08-04 10:07:57 -07:00
|
|
|
require "utils/spdx"
|
2020-06-23 01:39:10 +08:00
|
|
|
|
|
|
|
module Homebrew
|
2020-10-20 12:03:48 +02:00
|
|
|
extend T::Sig
|
|
|
|
|
2020-06-23 01:39:10 +08: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
|
|
|
|
usage_banner <<~EOS
|
2020-07-17 20:45:15 +10:00
|
|
|
`update-license-data` [<options>]
|
2020-06-23 02:25:46 +08:00
|
|
|
|
2020-06-29 16:20:07 +08:00
|
|
|
Update SPDX license data in the Homebrew repository.
|
2020-06-25 05:10:29 +08:00
|
|
|
EOS
|
2020-07-17 14:14:12 +01:00
|
|
|
switch "--fail-if-not-changed",
|
|
|
|
description: "Return a failing status code if current license data's version is the same as " \
|
2020-06-29 16:20:07 +08:00
|
|
|
"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
|
|
|
|
2020-06-25 05:46:18 +08:00
|
|
|
max_named 0
|
2020-06-23 01:39:10 +08:00
|
|
|
end
|
2020-06-25 05:46:18 +08:00
|
|
|
end
|
2020-06-23 01:39:10 +08:00
|
|
|
|
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
|
2020-06-29 16:20:07 +08:00
|
|
|
ohai "Updating SPDX license data..."
|
2020-06-30 15:18:10 +08:00
|
|
|
|
2020-08-04 10:07:57 -07:00
|
|
|
SPDX.download_latest_license_data!
|
2020-08-21 15:34:57 +01:00
|
|
|
return unless args.fail_if_not_changed?
|
2020-07-17 20:45:15 +10:00
|
|
|
|
2020-08-21 15:34:57 +01:00
|
|
|
Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX::DATA_PATH)
|
2020-06-23 01:39:10 +08:00
|
|
|
end
|
2020-06-25 05:46:18 +08:00
|
|
|
end
|