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

Feature Request: Separate go_deps in gazelle_dependencies to gazelle_go_dependencies. #1305

Open
BoleynSu opened this issue Jul 17, 2022 · 1 comment

Comments

@BoleynSu
Copy link

BoleynSu commented Jul 17, 2022

Current implementation forces user to declare go_repository before gazelle_dependencies to avoid being overridden. With seperated macros, user can introduce the whatever go_deps they want at whatever place.

This can be implemented as:

def gazelle_dependencies(enable_go_deps=True): # flip to False when all downstream have migrated or ask downstream to use False or also provide such option.
   if enable_go_deps:
      gazelle_go_dependencies()
def gazelle_go_dependencies(): # we can also add parameters to enable/disable any particular repo
  go_repo(...)

Now, we can use

something_that_deps_on_gazelle()
# no something_that_deps_on_gazelle_go_deps()
another_that_deps_on_gazelle(enable_go_deps=False)
gazelle_dependencies(enable_go_deps=False)
go_repo(name="my_go_deps")
@BoleynSu
Copy link
Author

BoleynSu commented Jul 17, 2022

Currently, we have to manually patch deps.bzl to achive the same.
https://github.com/BoleynSu-Org/monorepo/blob/b3680bcd9cff3a7270eb48d2d28bb7734a557e25/configs/deps/deps.bzl#L188

sfc-gh-ptabor added a commit to sfc-gh-ptabor/bazel-gazelle that referenced this issue Jul 20, 2023
- gazelle_init()
- gazelle_go_repositories()

Thanks to it, the caller can call go_repository in between,
loading their own (likely newer) version of the dependencies.

Currently `go_repository` cannot be called before `gazelle_dependencies`,
as the `bazel_gazelle_go_repository_cache` is not yet initialized.

Fixes problems like:
  - bazelbuild#1582
  - bazelbuild#1468
  - bazelbuild#1305
  -
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 a pull request may close this issue.

1 participant