Skip to content
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

Handle Bzlmod qualified repo names in coursier unpinned repo implementation #1203

Closed
wants to merge 3 commits into from

Conversation

plobsing
Copy link
Contributor

Under Bzlmod, repo names are qualified. Whereas a simple workspace with a single
@maven repo would have before had an unpinned repo named @unpinned_maven, now
this repo is named something like @rules_jvm_external~~maven~unpinned_maven.

Using str.rpartition by the ~ delimiter enables us to consistently
get the unqualified name in both cases:

>>> "rules_jvm_external~~maven~unpinned_maven".rpartition("~")
('rules_jvm_external~~maven', '~', 'unpinned_maven')
>>> "unpinned_maven".rpartition("~")
('', '', 'unpinned_maven')

After this change, the lockfile pinning script, @maven//:pin will use the local
machine's Coursier cache (~/Library/Caches/Coursier on MacOS) even under
Bzlmod. A populated cache makes version resolutions substantially faster to obtain.

Under Bzlmod, repo names are qualified. Whereas a simple workspace with a single
`@maven` repo would have before had an unpinned repo named `@unpinned_maven`, now
this repo is named something like `@rules_jvm_external~~maven~unpinned_maven`.

Using `str.rpartition` by the `~` delimiter enables us to consistently
get the unqualified name in both cases:

    >>> "rules_jvm_external~~maven~unpinned_maven".rpartition("~")
    ('rules_jvm_external~~maven', '~', 'unpinned_maven')
    >>> "unpinned_maven".rpartition("~")
    ('', '', 'unpinned_maven')
@Wyverald
Copy link
Contributor

Please try not to rely on the canonical repo name format, which is unstable. In fact, we're looking to change the ~ to + to address bazelbuild/bazel#22865. Instead, you could explicitly pass in the "unpinned-ness" of a repo as a boolean attribute.

@plobsing
Copy link
Contributor Author

Please try not to rely on the canonical repo name format, which is unstable. In fact, we're looking to change the ~ to + to address bazelbuild/bazel#22865. Instead, you could explicitly pass in the "unpinned-ness" of a repo as a boolean attribute.

Fair enough. I wasn't really a fan of the string munging going on, but ignored it to get the smallest patch that would solve my issue. Your way does seem cleaner to me, if we want to do that, its here: #1204 .
Demoting this PR to draft while that one is in flight (will close if it merges).

@plobsing plobsing marked this pull request as draft July 24, 2024 05:53
@plobsing plobsing closed this Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants