Merge pull request #10685 from kthchew/licenses-with-plus

utils/spdx: correctly detect non-deprecated licenses with plus
This commit is contained in:
Bo Anderson 2021-02-24 00:29:30 +00:00 committed by GitHub
commit 9b94234866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -132,10 +132,18 @@ describe SPDX do
expect(described_class.deprecated_license?("GPL-1.0")).to eq true
end
it "returns true for deprecated license identifier with plus" do
expect(described_class.deprecated_license?("GPL-1.0+")).to eq true
end
it "returns false for non-deprecated license identifier" do
expect(described_class.deprecated_license?("MIT")).to eq false
end
it "returns false for non-deprecated license identifier with plus" do
expect(described_class.deprecated_license?("EPL-1.0+")).to eq false
end
it "returns false for invalid license identifier" do
expect(described_class.deprecated_license?("foo")).to eq false
end

View File

@ -78,6 +78,7 @@ module SPDX
return false if ALLOWED_LICENSE_SYMBOLS.include? license
return false unless valid_license?(license)
license = license.delete_suffix "+"
license_data["licenses"].none? do |spdx_license|
spdx_license["licenseId"] == license && !spdx_license["isDeprecatedLicenseId"]
end