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

feat(license): add struct with types for licenses #256

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions pkg/conda/meta/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func (p *Parser) Parse(r dio.ReadSeekerAt) ([]types.Library, []types.Dependency,
}

return []types.Library{{
Name: data.Name,
Version: data.Version,
License: data.License, // can be empty
Name: data.Name,
Version: data.Version,
Licenses: types.LicensesFromString(data.License, types.LicenseTypeName),
}}, nil, nil
}
20 changes: 18 additions & 2 deletions pkg/conda/meta/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,28 @@ func TestParse(t *testing.T) {
{
name: "_libgcc_mutex",
input: "testdata/_libgcc_mutex-0.1-main.json",
want: []types.Library{{Name: "_libgcc_mutex", Version: "0.1"}},
want: []types.Library{
{
Name: "_libgcc_mutex",
Version: "0.1",
},
},
},
{
name: "libgomp",
input: "testdata/libgomp-11.2.0-h1234567_1.json",
want: []types.Library{{Name: "libgomp", Version: "11.2.0", License: "GPL-3.0-only WITH GCC-exception-3.1"}},
want: []types.Library{
{
Name: "libgomp",
Version: "11.2.0",
Licenses: types.Licenses{
{
Type: types.LicenseTypeName,
Value: "GPL-3.0-only WITH GCC-exception-3.1",
},
},
},
},
},
{
name: "invalid_json",
Expand Down
4 changes: 0 additions & 4 deletions pkg/java/pom/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ func (a artifact) Equal(o artifact) bool {
return a.GroupID == o.GroupID || a.ArtifactID == o.ArtifactID || a.Version.String() == o.Version.String()
}

func (a artifact) JoinLicenses() string {
return strings.Join(a.Licenses, ", ")
}

func (a artifact) ToPOMLicenses() pomLicenses {
return pomLicenses{
License: lo.Map(a.Licenses, func(lic string, _ int) pomLicense {
Expand Down
2 changes: 1 addition & 1 deletion pkg/java/pom/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (p *parser) parseRoot(root artifact) ([]types.Library, []types.Dependency,
ID: packageID(name, art.Version.String()),
Name: name,
Version: art.Version.String(),
License: art.JoinLicenses(),
Licenses: types.LicensesFromStringSlice(art.Licenses, types.LicenseTypeName), // Maven recommends using SPDX licenses - https://maven.apache.org/pom.html#licenses.
Indirect: !art.Direct,
Locations: art.Locations,
}
Expand Down
Loading