Skip to content

Commit

Permalink
if the same license is found in a LICENSE file twice, only return it …
Browse files Browse the repository at this point in the history
…once (#214)

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed Jul 9, 2023
1 parent e41525c commit 8da3933
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions licenses/classifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,20 @@ func (c *googleClassifier) Identify(licensePath string) ([]License, error) {
return nil, err
}

foundLicenseNames := map[string]struct{}{}

licenses := []License{}
for _, match := range matches.Matches {
if match.MatchType != "License" {
continue
}

// Skip duplicate licenses.
if _, ok := foundLicenseNames[match.Name]; ok {
continue
}
foundLicenseNames[match.Name] = struct{}{}

licenses = append(licenses, License{
Name: match.Name,
Type: LicenseType(match.Name),
Expand Down

0 comments on commit 8da3933

Please sign in to comment.