Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hard failing if module versions aren't aligned between bazel dep and …
…go.mod for a given module (#1957) **What type of PR is this?** >Bug fix/Change in behavior **What package or component does this PR mostly affect?** >go_deps **What does this PR do? Why is it needed?** If a given Go module is requested both via `go.mod` and directly as a `bazel_dep`, this PR will change Gazelle's behavior to hard fail as opposed to use the Bazel dep so long as it's a higher version than the one in `go.mod` Ideally, Gazelle should fail and alert the developer to the mismatch so that they may align the versions in order to ensure that Native Go builds use the same SoT as Bazel builds. Tested locally: ``` >bazel build //... INFO: Invocation ID: 09d43bbd-a6b9-4e9f-a0b0-094be01359bf ERROR: Traceback (most recent call last): File "/private/var/tmp/_bazel_smuthu/572bd1d287d7ec2c900673904e0dbb38/external/gazelle~/internal/bzlmod/go_deps.bzl", line 571, column 17, in _go_deps_impl fail("\n\nMismatch between versions requested for module {module}\nBazel dependency version requested in MODULE.bazel: {bazel_dep_version}\nGo module version requested in go.mod: {go_module_version}\nPlease resolve this mismatch to prevent discrepancies between native Go and Bazel builds\n\n".format( Error in fail: Mismatch between versions requested for module github.com/cloudflare/circl Bazel dependency version requested in MODULE.bazel: 1.3.8 Go module version requested in go.mod: 1.3.7 Please resolve this mismatch to prevent discrepancies between native Go and Bazel builds ERROR: error evaluating module extension go_deps in @@gazelle~//:extensions.bzl INFO: Elapsed time: 0.195s INFO: 0 processes. ERROR: Build did NOT complete successfully INFO: Build Event Protocol files produced successfully. FAILED: Fetching module extension go_deps in @@gazelle~//:extensions.bzl; starting ``` **Which issues(s) does this PR fix?** No issue currently but happy to create one if necessary [Bazel Slack Discussion](https://bazelbuild.slack.com/archives/C014RARENH0/p1728680692301999)
- Loading branch information