Skip to content

Commit

Permalink
go_deps should fail with a clear message when 2 modules that only dif…
Browse files Browse the repository at this point in the history
…fer in case are used (#1954)

**What type of PR is this?**
> Bug fix

**What package or component does this PR mostly affect?**
> go_deps

**What does this PR do? Why is it needed?**
Replaces #1949

---------

Co-authored-by: Fabian Meumertzheim <[email protected]>
  • Loading branch information
Buzz-Lightyear and fmeum authored Oct 11, 2024
1 parent 453d728 commit 8bbeae7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/bzlmod/go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def _go_deps_impl(module_ctx):
),
)

repos_processed = {}
for path, module in module_resolutions.items():
if hasattr(module, "module_name"):
# Do not create a go_repository for a Go module provided by a bazel_dep.
Expand All @@ -602,6 +603,14 @@ def _go_deps_impl(module_ctx):
# Do not create a go_repository for a dep shared with the non-isolated instance of
# go_deps.
continue
if module.repo_name in repos_processed:
fail("Go module {prev_path} and {path} will resolve to the same Bazel repo name: {name}. While Go allows modules to only differ in case, this isn't supported in Gazelle (yet). Please ensure you only use one of these modules in your go.mod(s)".format(
prev_path = repos_processed[module.repo_name],
path = path,
name = module.repo_name,
))

repos_processed[module.repo_name] = path
go_repository_args = {
"name": module.repo_name,
# Compared to the name attribute, the content of this attribute does not go through repo
Expand Down

0 comments on commit 8bbeae7

Please sign in to comment.