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

34 lines
914 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
require "cli/parser"
2020-08-04 10:07:57 -07:00
require "utils/spdx"
module Homebrew
module_function
2020-06-25 05:46:18 +08:00
def update_license_data_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`update-license-data` [<options>]
Update SPDX license data in the Homebrew repository.
2020-06-25 05:10:29 +08:00
EOS
switch "--fail-if-not-changed",
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-06-25 05:46:18 +08:00
max_named 0
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
ohai "Updating SPDX license data..."
2020-08-04 10:07:57 -07:00
SPDX.download_latest_license_data!
return unless args.fail_if_not_changed?
Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX::DATA_PATH)
end
2020-06-25 05:46:18 +08:00
end