Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/fix: support bzlmod #6191

Merged
merged 9 commits into from
Apr 2, 2024
Merged

cli/fix: support bzlmod #6191

merged 9 commits into from
Apr 2, 2024

Conversation

sluongng
Copy link
Contributor

@sluongng sluongng commented Mar 19, 2024

Ensure that bzlmod is correctly detected.

In case bzlmod is used, we need to query for the location of

  @@gazelle~override~go_deps~bazel_gazelle_go_repository_config//:WORKSPACE

so that we could feed it to Gazelle to generate BUILD files with correct
import.

@sluongng sluongng marked this pull request as draft March 19, 2024 15:49
@sluongng sluongng force-pushed the sluongng/cli-support-bzlmod branch 2 times, most recently from ca409fc to 779ca91 Compare March 20, 2024 13:53
@sluongng
Copy link
Contributor Author

There is a dependency between cli/bazelisk -> cli/workspace

this made it's not possible to use bazelisk inside workspace to call bazel info.

@sluongng
Copy link
Contributor Author

I want to trickle useModules down PathAndBasename() as well. However, it will lead to a bigger refactoring and potentially another cyclic deps.

I think we could make do with an assumption with PathAndBasename for now. If we need to fix it to be super accurate, we could do it after.

@sluongng sluongng marked this pull request as ready for review March 20, 2024 14:59
@sluongng sluongng force-pushed the sluongng/cli-support-bzlmod branch from 30b6566 to dbc8a26 Compare March 21, 2024 10:26
cli/bazelisk/bazelisk.go Outdated Show resolved Hide resolved
Comment on lines 75 to 79
// Prevent Bazelisk `log.Printf` call to write directly to stderr
oldWriter := log.Writer()
log.SetOutput(stderr)
defer log.SetOutput(oldWriter)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems OK to me to put this logic in Run() since to me the expected behavior of RunOpts would be that all stderr/stdout from bazelisk, including go logs, goes to the stdout/stderr writers passed in. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I tried fitting it in if RunOpts.stderr is set 🤔

cli/bzlmod/bzlmod.go Outdated Show resolved Hide resolved
cli/bzlmod/bzlmod.go Outdated Show resolved Hide resolved
Ensure that bzlmod is correctly detected.

In case bzlmod is used, we need to query for the location of

  @@gazelle~override~go_deps~bazel_gazelle_go_repository_config//:WORKSPACE

so that we could feed it to Gazelle to generate BUILD files with correct
import.
@sluongng sluongng force-pushed the sluongng/cli-support-bzlmod branch from 01127c3 to 6826477 Compare March 28, 2024 11:24
@sluongng sluongng merged commit f35a5f7 into master Apr 2, 2024
16 checks passed
@sluongng sluongng deleted the sluongng/cli-support-bzlmod branch April 2, 2024 08:20
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.

None yet

2 participants