From 3379d8ade2774ac9fcec48e7a7d1cde0707c3849 Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Wed, 20 Sep 2023 11:16:44 -0700 Subject: [PATCH] Respect subpackage no-provides Signed-off-by: Elizabeth Myers --- pkg/build/linter.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/build/linter.go b/pkg/build/linter.go index d2b826b41..2ceca5558 100644 --- a/pkg/build/linter.go +++ b/pkg/build/linter.go @@ -28,6 +28,21 @@ type LinterContext struct { chk *config.Checks } +func (lctx LinterContext) getPackageOptions() (*config.PackageOption, error) { + if lctx.pkgname == lctx.cfg.Package.Name { + return &lctx.cfg.Package.Options, nil + } + + for _, spkg := range lctx.cfg.Subpackages { + if lctx.pkgname == spkg.Name { + return &spkg.Options, nil + } + } + + // Shouldn't get here + return nil, fmt.Errorf("Could not locate package or subpackage!") +} + type linterFunc func(lctx LinterContext, path string, d fs.DirEntry) error type linter struct { @@ -173,7 +188,17 @@ func emptyPostLinter(lctx LinterContext, fsys fs.FS) error { return err } - if foundfile || lctx.cfg.Package.Options.NoProvides { + // Nothing to do + if foundfile { + return nil + } + + options, err := lctx.getPackageOptions() + if err != nil { + return err + } + + if options.NoProvides { // Nothing to do return nil }