Skip to content

Commit

Permalink
Updating repo naming scheme to distinguish importpaths that only diff…
Browse files Browse the repository at this point in the history
…er in case
  • Loading branch information
Buzz-Lightyear authored and Srinivas Muthu committed Oct 9, 2024
1 parent 7df94f2 commit 9ca14e9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/bzlmod/go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ def _repo_name(importpath):
path_segments = importpath.split("/")
segments = reversed(path_segments[0].split(".")) + path_segments[1:]
candidate_name = "_".join(segments).replace("-", "_")
return "".join([c.lower() if c.isalnum() else "_" for c in candidate_name.elems()])

def _encode_case(c):
"""Repo names end up as directory names, therefore we can't rely on case to distinguish importpaths that only differ in case"""
return "1" + c.lower() if c.isupper() else c

return "".join([_encode_case(c) if c.isalnum() else "_" for c in candidate_name.elems()])

def _is_dev_dependency(module_ctx, tag):
if hasattr(tag, "_is_dev_dependency"):
Expand Down Expand Up @@ -592,7 +597,6 @@ 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 @@ -603,10 +607,7 @@ 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:
continue

repos_processed[module.repo_name] = True
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 9ca14e9

Please sign in to comment.