fix: use "contents" field and remove "fullText" license field (#3857)

---------
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
Christopher Angelo Phillips
2025-05-05 21:40:09 +00:00
committed by GitHub
parent 6db60c5975
commit 1ba1186410
15 changed files with 64 additions and 40 deletions
@@ -80,7 +80,7 @@ func ParseLicenses(raw []pkg.License) (concluded, declared []SPDXLicense) {
func createSPDXLicense(l pkg.License) SPDXLicense {
candidate := SPDXLicense{
ID: generateLicenseID(l),
FullText: l.FullText,
FullText: l.Contents,
}
if l.SPDXExpression == "" {
@@ -96,7 +96,7 @@ func generateLicenseID(l pkg.License) string {
if l.Value != "" {
return spdxlicense.LicenseRefPrefix + SanitizeElementID(l.Value)
}
return licenseSum(l.FullText)
return licenseSum(l.Contents)
}
func licenseSum(s string) string {
@@ -116,7 +116,7 @@ func TestGenerateLicenseID(t *testing.T) {
license: pkg.License{
SPDXExpression: "Apache-2.0",
Value: "SomeValue",
FullText: "Some text",
Contents: "Some text",
},
expected: "Apache-2.0",
},
@@ -136,9 +136,9 @@ func TestGenerateLicenseID(t *testing.T) {
"LGPLv2--and-LGPLv2--with-exceptions-and-GPLv2--and-GPLv2--with-exceptions-and-BSD-and-Inner-Net-and-ISC-and-Public-Domain-and-GFDL",
},
{
name: "Uses hash of fullText when nothing else is provided",
name: "Uses hash of contents when nothing else is provided",
license: pkg.License{
FullText: "This is a very long custom license text that should be hashed because it's more than 64 characters long.",
Contents: "This is a very long custom license text that should be hashed because it's more than 64 characters long.",
},
expected: "", // We'll verify it starts with the correct prefix
},