rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

fix(gopackagesdriver): Improve wildcard package query matching

Open Aaronkala opened this issue 9 months ago • 3 comments

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

Improve wildcard package loading (./something/...) when using a custom bazelQueryScope e.g. //.... Currently, the queryFromRequests transformation results in a query like:

bazel query "kind(\"^(go_library) rule$\", attr(importpath, \"^./something(/.+)?$\", deps(//...)))"

which fails to return any results due to the ^ start of string matching. This PR also aligns the behaviour more closely to the "non wild card" behaviour (see) by omitting the ^.

When using go outside bazel, the following query is valid syntax and correctly loads all the packages under ./something/:

package.Load(cfg, "./something/...")

Which issues(s) does this PR fix?

No issue

Other notes for review

Aaronkala avatar Mar 06 '25 10:03 Aaronkala

What does the actual kind look like in that case that it doesn't match the start of string?

fmeum avatar Mar 06 '25 12:03 fmeum

@fmeum all the returned results without "^" start with // for example:

//something/foo/bar/foobar:baz
//something/foo:bar
//something/bar/foo:baz

I'm not sure if this is what you mean by "kind"

Aaronkala avatar Mar 06 '25 12:03 Aaronkala

Thanks, I thought this also affected the usage of ^ in the kind part of the query, but it doesn't.

fmeum avatar Mar 06 '25 12:03 fmeum