Skip to content

Commit

Permalink
chore: handle + in canonical repo name (#164)
Browse files Browse the repository at this point in the history
To prepare for bazelbuild/bazel#23098
  • Loading branch information
honnix authored Oct 16, 2024
1 parent e5c4f99 commit 7bfcd11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ruby/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def normalize_bzlmod_repository_name(name):
"""Converts Bzlmod repostory to its private name.
This is needed to define a target that is called the same as the repository.
For example, given a canonical name "rules_ruby~override~ruby~bundle",
For example, given a canonical name "rules_ruby+override+ruby+bundle" or
"rules_ruby~override~ruby~bundle",
the function would return "bundle" as the name.
This is a hacky workaround and will be fixed upstream.
Expand All @@ -156,6 +157,9 @@ def normalize_bzlmod_repository_name(name):
Returns:
repository name
"""
if "+" in name:
return name.rpartition("+")[-1]

return name.rpartition("~")[-1]

def to_rlocation_path(source):
Expand Down
1 change: 1 addition & 0 deletions ruby/tests/utils_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ load(
def _normalize_bzlmod_repository_name_test_impl(ctx):
env = unittest.begin(ctx)
asserts.equals(env, _normalize_bzlmod_repository_name("bundle"), "bundle")
asserts.equals(env, _normalize_bzlmod_repository_name("rules_ruby+override+ruby+bundle"), "bundle")
asserts.equals(env, _normalize_bzlmod_repository_name("rules_ruby~override~ruby~bundle"), "bundle")
return unittest.end(env)

Expand Down

0 comments on commit 7bfcd11

Please sign in to comment.