[rubygems/rubygems] Make nil a valid license spec
https://github.com/rubygems/rubygems/commit/675effb67e
This commit is contained in:
parent
4524aeba2f
commit
744bc4d5d0
@ -343,7 +343,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
String
|
String
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Array === val && val.all? {|x| x.is_a?(klass) }
|
unless Array === val && val.all? {|x| x.is_a?(klass) || (field == :licenses && x.nil?) }
|
||||||
error "#{field} must be an Array of #{klass}"
|
error "#{field} must be an Array of #{klass}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -358,6 +358,8 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
licenses = @specification.licenses
|
licenses = @specification.licenses
|
||||||
|
|
||||||
licenses.each do |license|
|
licenses.each do |license|
|
||||||
|
next if license.nil?
|
||||||
|
|
||||||
if license.length > 64
|
if license.length > 64
|
||||||
error "each license must be 64 characters or less"
|
error "each license must be 64 characters or less"
|
||||||
end
|
end
|
||||||
@ -368,11 +370,12 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
licenses = @specification.licenses
|
licenses = @specification.licenses
|
||||||
|
|
||||||
licenses.each do |license|
|
licenses.each do |license|
|
||||||
next if Gem::Licenses.match?(license)
|
next if Gem::Licenses.match?(license) || license.nil?
|
||||||
suggestions = Gem::Licenses.suggestions(license)
|
suggestions = Gem::Licenses.suggestions(license)
|
||||||
message = <<-WARNING
|
message = <<-WARNING
|
||||||
license value '#{license}' is invalid. Use a license identifier from
|
license value '#{license}' is invalid. Use a license identifier from
|
||||||
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
|
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
WARNING
|
WARNING
|
||||||
message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil?
|
message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil?
|
||||||
warning(message)
|
warning(message)
|
||||||
@ -380,7 +383,8 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
|
|||||||
|
|
||||||
warning <<-WARNING if licenses.empty?
|
warning <<-WARNING if licenses.empty?
|
||||||
licenses is empty, but is recommended. Use a license identifier from
|
licenses is empty, but is recommended. Use a license identifier from
|
||||||
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
|
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
WARNING
|
WARNING
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -199,7 +199,8 @@ class TestGemCommandsBuildCommand < Gem::TestCase
|
|||||||
|
|
||||||
error = @ui.error.split "\n"
|
error = @ui.error.split "\n"
|
||||||
assert_equal "WARNING: licenses is empty, but is recommended. Use a license identifier from", error.shift
|
assert_equal "WARNING: licenses is empty, but is recommended. Use a license identifier from", error.shift
|
||||||
assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.", error.shift
|
assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,", error.shift
|
||||||
|
assert_equal "or set it to nil if you don't want to specify a license.", error.shift
|
||||||
assert_equal "WARNING: See https://guides.rubygems.org/specification-reference/ for help", error.shift
|
assert_equal "WARNING: See https://guides.rubygems.org/specification-reference/ for help", error.shift
|
||||||
assert_equal [], error
|
assert_equal [], error
|
||||||
|
|
||||||
|
@ -3086,10 +3086,22 @@ Please report a bug if this causes problems.
|
|||||||
|
|
||||||
assert_match <<-WARNING, @ui.error
|
assert_match <<-WARNING, @ui.error
|
||||||
WARNING: licenses is empty, but is recommended. Use a license identifier from
|
WARNING: licenses is empty, but is recommended. Use a license identifier from
|
||||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
WARNING
|
WARNING
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_validate_nil_license
|
||||||
|
util_setup_validate
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@a1.license = nil
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_empty @ui.error
|
||||||
|
end
|
||||||
|
|
||||||
def test_validate_license_in_a_non_packaging_context
|
def test_validate_license_in_a_non_packaging_context
|
||||||
util_setup_validate
|
util_setup_validate
|
||||||
|
|
||||||
@ -3126,7 +3138,8 @@ http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
|||||||
|
|
||||||
assert_match <<-WARNING, @ui.error
|
assert_match <<-WARNING, @ui.error
|
||||||
WARNING: license value 'BSD' is invalid. Use a license identifier from
|
WARNING: license value 'BSD' is invalid. Use a license identifier from
|
||||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
WARNING
|
WARNING
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3184,11 +3197,13 @@ http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
|||||||
|
|
||||||
assert_match <<-WARNING, @ui.error
|
assert_match <<-WARNING, @ui.error
|
||||||
WARNING: license value 'GPL-2.0+ FOO' is invalid. Use a license identifier from
|
WARNING: license value 'GPL-2.0+ FOO' is invalid. Use a license identifier from
|
||||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
WARNING
|
WARNING
|
||||||
assert_match <<-WARNING, @ui.error
|
assert_match <<-WARNING, @ui.error
|
||||||
WARNING: license value 'GPL-2.0 FOO' is invalid. Use a license identifier from
|
WARNING: license value 'GPL-2.0 FOO' is invalid. Use a license identifier from
|
||||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
WARNING
|
WARNING
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3202,7 +3217,8 @@ http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
|||||||
|
|
||||||
assert_match <<-WARNING, @ui.error
|
assert_match <<-WARNING, @ui.error
|
||||||
WARNING: license value 'GPL-2.0+ WITH Autocofn-exception-2.0' is invalid. Use a license identifier from
|
WARNING: license value 'GPL-2.0+ WITH Autocofn-exception-2.0' is invalid. Use a license identifier from
|
||||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
WARNING
|
WARNING
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3216,7 +3232,8 @@ http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
|||||||
|
|
||||||
assert_match <<-WARNING, @ui.error
|
assert_match <<-WARNING, @ui.error
|
||||||
WARNING: license value 'ruby' is invalid. Use a license identifier from
|
WARNING: license value 'ruby' is invalid. Use a license identifier from
|
||||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,
|
||||||
|
or set it to nil if you don't want to specify a license.
|
||||||
Did you mean 'Ruby'?
|
Did you mean 'Ruby'?
|
||||||
WARNING
|
WARNING
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user