diff --git a/ruby/private/utils.bzl b/ruby/private/utils.bzl index a306913f..3b04db9e 100644 --- a/ruby/private/utils.bzl +++ b/ruby/private/utils.bzl @@ -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. @@ -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): diff --git a/ruby/tests/utils_tests.bzl b/ruby/tests/utils_tests.bzl index 385be3bb..b79ae8ed 100644 --- a/ruby/tests/utils_tests.bzl +++ b/ruby/tests/utils_tests.bzl @@ -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)