bazelbuild / bazel-gazelle

Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.18k stars 373 forks source link

Bug: when the go code embedded a file that located in another package gazelle will ignore that file #1681

Open ninjadq opened 9 months ago

ninjadq commented 9 months ago

What version of gazelle are you using?

0.34.0

What version of rules_go are you using?

0.41.0

What version of Bazel are you using?

v1.11.0

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Ubuntu, AMD64

What did you do?

Run gazelle for this xk6-browser project.

git clone https://github.com/grafana/xk6-browser.git
cd xk6-browser
## run command
gezelle

An Error message like pattern js/injected_script.js: matched no files occured. But that file does exist common/js/injected_script. It embeds from this file common/execution_context.go

I think there is a bug when handling an embedded file located in a sub directory and that directory is another bazel package.

common/
common/BUILD.bazel
common/execution_context.go // embedding a js file
...
common/js/
common/js/BUILD.bazel
common/js/injected_script.js // embedded js file
...

What did you expect to see?

gazelle run without error

What did you see instead?

error msg like

/xxx//gazelle 
gazelle: /xxx/com_github_grafana_xk6_browser/common/execution_context.go:242:2: pattern js/injected_script.js: matched no files
ninjadq commented 9 months ago

The code removed in this PR https://github.com/bazelbuild/bazel-gazelle/pull/1682/files

I think is the root cause. Because it cut the desired dir before check the file