diff --git a/lib/private/utils.bzl b/lib/private/utils.bzl index d775d55..d1441c6 100644 --- a/lib/private/utils.bzl +++ b/lib/private/utils.bzl @@ -76,11 +76,8 @@ def _is_external_label(param): Returns: a bool """ - - # Seems like a bug in Bazel that the workspace_root for a label like - # @@//js/private/node-patches:fs.js is "external" - # See https://github.com/bazelbuild/bazel/issues/16528 - if str(param).startswith("@@//"): + if not _is_bazel_6_or_greater() and str(param).startswith("@@//"): + # Work-around for https://github.com/bazelbuild/bazel/issues/16528 return False return len(_to_label(param).workspace_root) > 0 diff --git a/lib/tests/utils_test.bzl b/lib/tests/utils_test.bzl index 0f4c808..db15aa4 100644 --- a/lib/tests/utils_test.bzl +++ b/lib/tests/utils_test.bzl @@ -51,12 +51,13 @@ def _is_external_label_test_impl(ctx): asserts.false(env, utils.is_external_label("//some/label")) asserts.false(env, utils.is_external_label(Label("//some/label"))) asserts.false(env, utils.is_external_label("@//some/label")) - - # TODO(Bazel 6.0): enable this test when the @@ syntax is available - # asserts.false(env, utils.is_external_label("@@//some/label")) asserts.false(env, utils.is_external_label(Label("@aspect_bazel_lib//some/label"))) asserts.false(env, ctx.attr.internal_with_workspace_as_string) + # the "@@" repository name syntax applies to Bazel 6 or greater + if utils.is_bazel_6_or_greater(): + asserts.false(env, utils.is_external_label("@@//some/label")) + # assert that labels and string that give a workspace return true asserts.true(env, utils.is_external_label(Label("@foo//some/label"))) asserts.true(env, ctx.attr.external_as_string)