-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add repository_ctx.original_name
#25121
Conversation
"The name that was originally specified as the 'name' attribute when this repository rule was instantiated. This name is not necessarily unique among external repositories (see 'name').") | ||
public String getOriginalName() { | ||
String originalName = (String) rule.getAttr("$original_name", Type.STRING); | ||
// The original name isn't set for WORKSPACE-defined repositories as well as repositories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these still a thing at HEAD? What's our strategy for backporting this, should I add new tests to the backports?
@Wyverald @meteorcloudy Since rulesets still have to support WORKSPACE at this point, in which
We wouldn't be able to cherry-pick the change, but for backwards compatibility users already need to resort to canonical repo name parsing where necessary (e.g. repo rules meant to be used with
Implementing this wouldn't be difficult, we could just monkey patch the |
I don't have strong preference on either way, I trust you and @Wyverald to make the best decision. But we should definitely document the best practices somewhere, I can follow up on that. |
I don't quite follow this logic -- currently, in either Bzlmod or WORKSPACE, it's always true that Although TBH I agree that if we were to start from scratch, having the |
They are equal today, but I doubt anyone relies on that property. What I (badly) described above is that a repo rule today must be prepared to receive both If you don't think that's doable, I'm also happy to go with the approach that's currently implemented by this PR. |
What I meant is that, technically, a repo rule could be relying on the semantics that With that said, I am struggling to think of a realistic example of such a repo rule... but IMO introducing an explicit API could avoid some headache in the future. Not a super strong opinion. |
We aren't locking us in, we could still change the behavior of |
@bazel-io fork 8.1.0 |
@fmeum can you please resolve the conflicts? Thanks |
This new attribute contains the original value of the `name` attribute at the instantiation site of the repo rule (e.g., `rctx.original_name` would be `foo` if `rctx.name` is `+ext+foo`). # Conflicts: # src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java
f992e42
to
6c65262
Compare
@iancha1992 Done! |
@fmeum could you please take a look at the presubmit failures? |
6c65262
to
a50b755
Compare
@satyanandak Fixed |
This new attribute contains the original value of the `name` attribute at the instantiation site of the repo rule (e.g., `rctx.original_name` would be `foo` if `rctx.name` is `+ext+foo`). Fixes bazelbuild#24467 Closes bazelbuild#25121. RELNOTES: Added `repository_ctx.original_name`, which contains the original value of the `name` attribute as specified at the repo rule call site. PiperOrigin-RevId: 722731393 Change-Id: I2f7dada0c44b6bd4c0d2622fa1e97223382a8547 (cherry picked from commit 8bcfb06)
This new attribute contains the original value of the `name` attribute at the instantiation site of the repo rule (e.g., `rctx.original_name` would be `foo` if `rctx.name` is `+ext+foo`). Fixes bazelbuild#24467 Closes bazelbuild#25121. RELNOTES: Added `repository_ctx.original_name`, which contains the original value of the `name` attribute as specified at the repo rule call site. PiperOrigin-RevId: 722731393 Change-Id: I2f7dada0c44b6bd4c0d2622fa1e97223382a8547 (cherry picked from commit 8bcfb06)
This new attribute contains the original value of the `name` attribute at the instantiation site of the repo rule (e.g., `rctx.original_name` would be `foo` if `rctx.name` is `+ext+foo`). Fixes bazelbuild#24467 Closes bazelbuild#25121. RELNOTES: Added `repository_ctx.original_name`, which contains the original value of the `name` attribute as specified at the repo rule call site. PiperOrigin-RevId: 722731393 Change-Id: I2f7dada0c44b6bd4c0d2622fa1e97223382a8547 (cherry picked from commit 8bcfb06)
This new attribute contains the original value of the `name` attribute at the instantiation site of the repo rule (e.g., `rctx.original_name` would be `foo` if `rctx.name` is `+ext+foo`). Fixes #24467 Closes #25121. RELNOTES: Added `repository_ctx.original_name`, which contains the original value of the `name` attribute as specified at the repo rule call site. PiperOrigin-RevId: 722731393 Change-Id: I2f7dada0c44b6bd4c0d2622fa1e97223382a8547 (cherry picked from commit 8bcfb06) Fixes #25147
This new attribute contains the original value of the
name
attribute at the instantiation site of the repo rule (e.g.,rctx.original_name
would befoo
ifrctx.name
is+ext+foo
).Fixes #24467