diff --git a/Library/Homebrew/dev-cmd/update-license-data.rb b/Library/Homebrew/dev-cmd/update-license-data.rb index afcca90291..c2f9f45d29 100644 --- a/Library/Homebrew/dev-cmd/update-license-data.rb +++ b/Library/Homebrew/dev-cmd/update-license-data.rb @@ -22,6 +22,11 @@ module Homebrew switch "--fail-if-outdated", description: "Return a failing status code if current license data's version is different from the upstream. This "\ "can be used to notify CI when the SPDX license data is out of date." + + switch "--do-not-replace", + description: "Flags out discrepancy between local and upstream versions, but does not replace" + + max_named 0 end end @@ -39,16 +44,16 @@ module Homebrew updated_spdx_hash = JSON.parse(updated_spdx_string) if curr_spdx_hash["licenseListVersion"] != updated_spdx_hash["licenseListVersion"] - puts "Current version is #{curr_spdx_hash["licenseListVersion"]} but newest version is #{updated_spdx_hash["licenseListVersion"]}\n"\ - "Updating existing licences data file..." - File.open(SPDX_FOLDER_PATH/FILE_NAME, "wb") do |file| - file.write(updated_spdx_string) - end - if args.fail_if_outdated - Homebrew.failed = true - end + puts "Current version is #{curr_spdx_hash["licenseListVersion"]} but newest version is #{updated_spdx_hash["licenseListVersion"]}" + unless args.do_not_replace? + puts "Updating existing licences data file..." + File.open(SPDX_FOLDER_PATH/FILE_NAME, "wb") do |file| + file.write(updated_spdx_string) + end end + Homebrew.failed = !!args.fail_if_outdated else puts "Current version of license data is updated. No change required" 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 new file mode 100644 index 0000000000..279332f87e --- /dev/null +++ b/Library/Homebrew/test/dev-cmd/update_license_data_spec.rb @@ -0,0 +1,9 @@ +require 'rspec' + +describe 'My behaviour' do + + it 'should do something' do + + true.should == false + end +end \ No newline at end of file