bazel-gazelle icon indicating copy to clipboard operation
bazel-gazelle copied to clipboard

feat(bzlmod: `go_deps.from_file`) to add default tags/directives

Open tyler-french opened this issue 11 months ago • 1 comments

In WORKSPACE, we can run gazelle update-repos with the following args:

  "bazel run //:gazelle -- \
    "update-repos" \
    "-prune" \
    "--from_file=src/code.uber.internal/go.mod" \
    "-build_file_proto_mode=disable" \
    "-build_file_generation=on" \
    "-build_extra_args=-go_naming_convention_external=go_default_library" \
...
}

This automatically applies certain constraints to all of our go_repository rules.

However, in go_deps.from_file, we need to apply a gazelle_override to every repo (which ends up being hundreds).

The proposal is to add optional arguments to the from file tag:

go_deps.from_file(
  go_mod = "//src/code.uber.internal:go.mod",
  build_file_generation = "on",
  build_extra_args = [
    "-go_naming_convention_external=go_default_library",
  ],
  directives = [
    "gazelle:proto disable",
  ],
)

What did you expect to see?

What did you see instead?

tyler-french avatar Sep 15 '23 15:09 tyler-french

Maybe we should just make gazelle:proto disable and build_file_generation = "on" the global defaults for Gazelle? @linzhp has brought that up before.

fmeum avatar Sep 15 '23 15:09 fmeum