Skip to content

Commit

Permalink
Merge pull request #10685 from kthchew/licenses-with-plus
Browse files Browse the repository at this point in the history
utils/spdx: correctly detect non-deprecated licenses with plus
  • Loading branch information
Bo98 authored Feb 24, 2021
2 parents 3efab3e + edead95 commit 9b94234
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Library/Homebrew/test/utils/spdx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,18 @@
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
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/utils/spdx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def deprecated_license?(license)
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
Expand Down

0 comments on commit 9b94234

Please sign in to comment.