-
-
Notifications
You must be signed in to change notification settings - Fork 287
Update repo name handling for Bzlmod compatibility #1621
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
Merged
simuons
merged 8 commits into
bazel-contrib:master
from
mbland:bzlmod-apparent-repo-name
Oct 24, 2024
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2c076f2
Add repo name macros for Bzlmod compatibility
mbland 2047e58
Bazel 5 updates from bazelbuild/bazel-skylib#548
mbland 9734174
Fix _MAIN_REPO_PREFIX in bzlmod.bzl
mbland 9c6f004
Expand dependency tracking patterns using Label
mbland 02f3605
Fix `scala_toolchains` lint error
mbland a3d5165
Use `apparent_repo_name` only on `repository_ctx`
mbland a4b20f0
Update `_jvm_import_external` JAR alias target
mbland f6dbab1
Fix typo in apparent_repo_name comment
mbland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Utilities for working with Bazel modules""" | ||
|
||
def apparent_repo_name(repository_ctx): | ||
"""Generates a repository's apparent name from a repository_ctx object. | ||
|
||
Args: | ||
repository_ctx: a repository_ctx object | ||
|
||
Returns: | ||
An apparent repo name derived from repository_ctx.name | ||
""" | ||
repo_name = repository_ctx.name | ||
|
||
# Bazed on this pattern from the Bazel source: | ||
# com.google.devtools.build.lib.cmdline.RepositoryName.VALID_REPO_NAME | ||
for i in range(len(repo_name) - 1, -1, -1): | ||
c = repo_name[i] | ||
if not (c.isalnum() or c in "_-."): | ||
return repo_name[i + 1:] | ||
|
||
return repo_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit:
Bazed
->Based
?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.
D'oh! Fixed, thanks! Like I say in the new commit message, I hate sloppy comments, and hate it more when I write them!