Skip to content

Commit

Permalink
licensescan: fix ignore handling (#3740)
Browse files Browse the repository at this point in the history
The previous logic did not work correctly.
  • Loading branch information
justinsb committed Jan 19, 2023
1 parent 3a99e3a commit b1a870b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/licensescan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ func RunLicenseScan(ctx context.Context, opts RunLicenseScanOptions) error {

var modules []*Module
for _, dep := range buildInfo.Deps {
ignore := false
for _, ignorePackage := range opts.IgnorePackage {
if ignorePackage == dep.Path {
klog.Infof("ignoring package %s@%s", dep.Path, dep.Version)
continue
ignore = true
break
}
}
if ignore {
continue
}

module := &Module{
// Path: dep.Path,
Expand Down Expand Up @@ -166,7 +171,7 @@ func RunLicenseScan(ctx context.Context, opts RunLicenseScanOptions) error {
if len(errors) == 0 && opts.IncludeLicenses {
for _, module := range modules {
if licenseFiles, err := includeLicense(ctx, module); err != nil {
errors = append(errors, fmt.Errorf("error getting license for %s@%s: %w", module.Name, module.Version, err))
errors = append(errors, fmt.Errorf("error getting license text for %s@%s: %w", module.Name, module.Version, err))
} else {
module.LicenseFiles = licenseFiles
}
Expand Down

0 comments on commit b1a870b

Please sign in to comment.