Skip to content

Commit

Permalink
Mark go_deps extension as reproducible (#1761)
Browse files Browse the repository at this point in the history
This removes the duplication of Go dependency information between
`go.mod`/`go.sum` and `MODULE.bazel.lock`.
  • Loading branch information
fmeum authored Mar 22, 2024
1 parent b3cddc0 commit de6bd68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module(
repo_name = "bazel_gazelle",
)

bazel_dep(name = "bazel_features", version = "1.9.0")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "protobuf", version = "3.19.6", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_go", version = "0.44.0", repo_name = "io_bazel_rules_go")
Expand Down
5 changes: 5 additions & 0 deletions internal/bzlmod/go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ load(
"get_directive_value",
"with_replaced_or_new_fields",
)
load("@bazel_features//:features.bzl", "bazel_features")

visibility("//")

Expand Down Expand Up @@ -553,6 +554,9 @@ def _go_deps_impl(module_ctx):
go_env = go_env,
)

metadata_kwargs = {}
if bazel_features.external_deps.extension_metadata_has_reproducible:
metadata_kwargs["reproducible"] = True
return _extension_metadata(
module_ctx,
root_module_direct_deps = root_module_direct_deps.keys(),
Expand All @@ -563,6 +567,7 @@ def _go_deps_impl(module_ctx):
for repo_name in root_module_direct_dev_deps.keys()
if repo_name not in root_module_direct_deps
}.keys(),
**metadata_kwargs
)

def _get_sum_from_module(path, module, sums):
Expand Down
2 changes: 1 addition & 1 deletion tests/bcr/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.2
7.1.1

0 comments on commit de6bd68

Please sign in to comment.