Skip to content

fix(gopackagesdriver): Improve wildcard package query matching#4288

Merged
fmeum merged 2 commits intobazel-contrib:masterfrom
Aaronkala:omit-start-only-wildcard-matching
Jan 8, 2026
Merged

fix(gopackagesdriver): Improve wildcard package query matching#4288
fmeum merged 2 commits intobazel-contrib:masterfrom
Aaronkala:omit-start-only-wildcard-matching

Conversation

@Aaronkala
Copy link
Copy Markdown
Contributor

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

@fmeum
Copy link
Copy Markdown
Member

fmeum commented Mar 6, 2025

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

@Aaronkala
Copy link
Copy Markdown
Contributor Author

Aaronkala commented Mar 6, 2025

@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"

@fmeum
Copy link
Copy Markdown
Member

fmeum commented Mar 6, 2025

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

@Aaronkala Aaronkala requested a review from fmeum March 6, 2025 19:26
@fmeum fmeum enabled auto-merge (squash) March 6, 2025 22:37
@fmeum fmeum disabled auto-merge March 6, 2025 22:37
@fmeum fmeum force-pushed the omit-start-only-wildcard-matching branch from 23be4f0 to e7568c5 Compare January 7, 2026 09:15
@fmeum fmeum enabled auto-merge (squash) January 7, 2026 09:15
@fmeum fmeum merged commit 23b3f09 into bazel-contrib:master Jan 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants