Fix error reporting in MatchesIncludeTags
ctx.ModuleErrorf for the main blueprint config object doesn't report an error, it just returns it. If go had something like C++'s `[[nodiscard]]` or rust's `#[must_use]` that would be useful here, but the issue has been open since 2017: https://github.com/golang/go/issues/20803 Test: Presubmits Change-Id: I72709e6c5466d55f5c0f3fe51a25c29df0826271
This commit is contained in:
parent
d2f1141871
commit
894b318528
1 changed files with 10 additions and 6 deletions
16
context.go
16
context.go
|
@ -1068,8 +1068,12 @@ func shouldVisitFile(c *Context, file *parser.File) shouldVisitFileInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
if blueprintPackageIncludes != nil {
|
if blueprintPackageIncludes != nil {
|
||||||
packageMatches := blueprintPackageIncludes.MatchesIncludeTags(c)
|
packageMatches, err := blueprintPackageIncludes.matchesIncludeTags(c)
|
||||||
if !packageMatches {
|
if err != nil {
|
||||||
|
return shouldVisitFileInfo{
|
||||||
|
errs: []error{err},
|
||||||
|
}
|
||||||
|
} else if !packageMatches {
|
||||||
return shouldVisitFileInfo{
|
return shouldVisitFileInfo{
|
||||||
shouldVisitFile: false,
|
shouldVisitFile: false,
|
||||||
skippedModules: skippedModules,
|
skippedModules: skippedModules,
|
||||||
|
@ -5265,14 +5269,14 @@ func (pi *PackageIncludes) MatchAll() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if all requested include tags are set in the Context object
|
// Returns true if all requested include tags are set in the Context object
|
||||||
func (pi *PackageIncludes) MatchesIncludeTags(ctx *Context) bool {
|
func (pi *PackageIncludes) matchesIncludeTags(ctx *Context) (bool, error) {
|
||||||
if len(pi.MatchAll()) == 0 {
|
if len(pi.MatchAll()) == 0 {
|
||||||
ctx.ModuleErrorf(pi, "Match_all must be a non-empty list")
|
return false, ctx.ModuleErrorf(pi, "Match_all must be a non-empty list")
|
||||||
}
|
}
|
||||||
for _, includeTag := range pi.MatchAll() {
|
for _, includeTag := range pi.MatchAll() {
|
||||||
if !ctx.ContainsIncludeTag(includeTag) {
|
if !ctx.ContainsIncludeTag(includeTag) {
|
||||||
return false
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue