Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "or-later" suffix updated to consider deprecated "+" operator #1907

Merged
merged 5 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions internal/spdxlicense/generate/generate_license_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,23 @@ func Test_processSPDXLicense(t *testing.T) {
"afl3.0.0": "AFL-3.0",
"afmparse": "Afmparse",
"agpl1": "AGPL-1.0-only",
"agpl1+": "AGPL-1.0-or-later",
"agpl1.0": "AGPL-1.0-only",
"agpl1.0+": "AGPL-1.0-or-later",
"agpl1.0.0": "AGPL-1.0-only",
"agpl1.0.0+": "AGPL-1.0-or-later",
"agpl1.0.0only": "AGPL-1.0-only",
"agpl1.0.0orlater": "AGPL-1.0-or-later",
"agpl1.0only": "AGPL-1.0-only",
"agpl1.0orlater": "AGPL-1.0-or-later",
"agpl1only": "AGPL-1.0-only",
"agpl1orlater": "AGPL-1.0-or-later",
"agpl3": "AGPL-3.0-only",
"agpl3+": "AGPL-3.0-or-later",
"agpl3.0": "AGPL-3.0-only",
"agpl3.0+": "AGPL-3.0-or-later",
"agpl3.0.0": "AGPL-3.0-only",
"agpl3.0.0+": "AGPL-3.0-or-later",
"agpl3.0.0only": "AGPL-3.0-only",
"agpl3.0.0orlater": "AGPL-3.0-or-later",
"agpl3.0only": "AGPL-3.0-only",
Expand Down Expand Up @@ -548,8 +554,17 @@ func Test_processSPDXLicense(t *testing.T) {
"ftl": "FTL",
"gd": "GD",
"gfdl1": "GFDL-1.1-only",
"gfdl1+": "GFDL-1.1-or-later",
"gfdl1+invariants": "GFDL-1.1-invariants-or-later",
"gfdl1+noinvariants": "GFDL-1.1-no-invariants-or-later",
"gfdl1.1": "GFDL-1.1-only",
"gfdl1.1+": "GFDL-1.1-or-later",
"gfdl1.1+invariants": "GFDL-1.1-invariants-or-later",
"gfdl1.1+noinvariants": "GFDL-1.1-no-invariants-or-later",
"gfdl1.1.0": "GFDL-1.1-only",
"gfdl1.1.0+": "GFDL-1.1-or-later",
"gfdl1.1.0+invariants": "GFDL-1.1-invariants-or-later",
"gfdl1.1.0+noinvariants": "GFDL-1.1-no-invariants-or-later",
"gfdl1.1.0invariantsonly": "GFDL-1.1-invariants-only",
"gfdl1.1.0invariantsorlater": "GFDL-1.1-invariants-or-later",
"gfdl1.1.0noinvariantsonly": "GFDL-1.1-no-invariants-only",
Expand All @@ -563,7 +578,13 @@ func Test_processSPDXLicense(t *testing.T) {
"gfdl1.1only": "GFDL-1.1-only",
"gfdl1.1orlater": "GFDL-1.1-or-later",
"gfdl1.2": "GFDL-1.2-only",
"gfdl1.2+": "GFDL-1.2-or-later",
"gfdl1.2+invariants": "GFDL-1.2-invariants-or-later",
"gfdl1.2+noinvariants": "GFDL-1.2-no-invariants-or-later",
"gfdl1.2.0": "GFDL-1.2-only",
"gfdl1.2.0+": "GFDL-1.2-or-later",
"gfdl1.2.0+invariants": "GFDL-1.2-invariants-or-later",
"gfdl1.2.0+noinvariants": "GFDL-1.2-no-invariants-or-later",
"gfdl1.2.0invariantsonly": "GFDL-1.2-invariants-only",
"gfdl1.2.0invariantsorlater": "GFDL-1.2-invariants-or-later",
"gfdl1.2.0noinvariantsonly": "GFDL-1.2-no-invariants-only",
Expand All @@ -577,7 +598,13 @@ func Test_processSPDXLicense(t *testing.T) {
"gfdl1.2only": "GFDL-1.2-only",
"gfdl1.2orlater": "GFDL-1.2-or-later",
"gfdl1.3": "GFDL-1.3-only",
"gfdl1.3+": "GFDL-1.3-or-later",
"gfdl1.3+invariants": "GFDL-1.3-invariants-or-later",
"gfdl1.3+noinvariants": "GFDL-1.3-no-invariants-or-later",
"gfdl1.3.0": "GFDL-1.3-only",
"gfdl1.3.0+": "GFDL-1.3-or-later",
"gfdl1.3.0+invariants": "GFDL-1.3-invariants-or-later",
"gfdl1.3.0+noinvariants": "GFDL-1.3-no-invariants-or-later",
"gfdl1.3.0invariantsonly": "GFDL-1.3-invariants-only",
"gfdl1.3.0invariantsorlater": "GFDL-1.3-invariants-or-later",
"gfdl1.3.0noinvariantsonly": "GFDL-1.3-no-invariants-only",
Expand Down
7 changes: 6 additions & 1 deletion internal/spdxlicense/generate/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ func (l License) canReplace(deprecated License) bool {

func buildLicenseIDPermutations(cleanID string) (perms []string) {
lv := findLicenseVersion(cleanID)
addPlusPermutation := strings.HasSuffix(cleanID, "orlater")
vp := versionPermutations(lv)

permSet := strset.New()
version := strings.Join(lv, ".")
for _, p := range vp {
if addPlusPermutation {
base := strings.TrimSuffix(cleanID, "orlater")
plus := p + "+"
permSet.Add(strings.Replace(base, version, plus, 1))
}
permSet.Add(strings.Replace(cleanID, version, p, 1))
}

Expand Down
3 changes: 3 additions & 0 deletions internal/spdxlicense/generate/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ func TestLicensePermutations(t *testing.T) {
"gpl3orlater",
"gpl3.0orlater",
"gpl3.0.0orlater",
"gpl3.0.0+",
"gpl3.0+",
"gpl3+",
},
},
{
Expand Down
29 changes: 28 additions & 1 deletion internal/spdxlicense/license_list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/spdxlicense/license_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ func TestLicenceListIDs(t *testing.T) {
assert.Equal(t, "ZPL-2.1", licenseIDs["zpl2.1"])
assert.Equal(t, "GPL-2.0-only", licenseIDs["gpl2"])
assert.Equal(t, "GPL-2.0-or-later", licenseIDs["gpl2+"])
assert.Equal(t, "GFDL-1.2-or-later", licenseIDs["gfdl1.2+"])
assert.NotEmpty(t, Version)
}